Hello !
Is there any way to return the name of the fields where it was found a search using, for example, conditional "OR" or any other ???
DataBase:
....
{ _id:1, name: 'Angel', lastName: "Rodriguez" },
{ _id:2, name: 'Jose', lastName: "Perez" },
{ _id:3, name: 'Janeth', lastName: "Sanchez" },
{ _id:4, name: 'Carmen', lastName: "Romero" }
....
Query:
dbPeople.find({}).
or([{ name: /ne/i }, { lastName: /dr/i }]).exec(callback);
Result:
{ _id:1, name: 'Angel', lastName: "Rodriguez" },
{ _id:3, name: 'Janeth', lastName: "Sanchez" },
Issue....
Document _id:1 matches, because the query found a match in the "lastName" field. How I can know that it was in this field?
Document _id:2 matches, because the query found a match in the "name" field. How I can know that it was in this field?
Thanks !!!