If I have the following DB model in mongoose
Employee{
FirstName : String,
LastName : String,
Job : String,
}
and I have two docs that look like this:
{
FirstName : Bob,
LastName : Jackson
Job : Professor
}
{
FirstName : Michael,
LastName : Jackson,
Job : Professor,
}
if I have a query that does the following:
Employee.find{FirstName : "Michael" , LastName : NULL, Job : NULL}
It will return null.
Instead I want to ignore the fields that have parameters equal to NULL as they do not exist in the query and the query above I wanted to be treated as :
Employee.find{“FirstName : Michael”}
how can I do that?