Mongoose - Find(): Object Inside Search Options Is Not Working
I have a mongoose Schema that looks like this: var mySchema = new mongoose.Schema({ ... metadata: { isDeleted: { type: Boolean, default: false }, ...
Solution 1:
It seems pretty likely given your use of elipsis in your schema listing that there are more properties than isDeleted
under the metadata
property. So your object should be:
var searchOptions = { "metadata.isDeleted": false } };
The reason for this is that otherwise the query is looking for a document with "exactly" and "only" the properties named under the metadata
key:
varsearchOptions= { metadata: { isDeleted:false } };
And when that is not the case, then of course there is no match.
Post a Comment for "Mongoose - Find(): Object Inside Search Options Is Not Working"