Sorting by virtual field in mongoDB (mongoose) Sorting by virtual field in mongoDB (mongoose) mongoose mongoose

Sorting by virtual field in mongoDB (mongoose)


You won't be able to sort by a virtual field because they are not stored to the database.

Virtual attributes are attributes that are convenient to have around but that do not get persisted to mongodb.

http://mongoosejs.com/docs/2.7.x/docs/virtuals.html