Querying on a virtual property in mongoose Querying on a virtual property in mongoose mongodb mongodb

Querying on a virtual property in mongoose


No, you can't. Mongoose virtual properties only exist in the Mongoose model representation of documents, not in MongoDB itself where the query is performed.

Any field you need to query against must be defined in the schema as a non-virtual field and persisted to the database.