Sorting by virtual field in mongoDB (mongoose)

前端 未结 1 1697
借酒劲吻你
借酒劲吻你 2020-12-06 17:16

Let\'s say I have some Schema which has a virtual field like this

var schema = new mongoose.Schema(
{
    name: { type: String }
},
{
    toObject: { virtual         


        
相关标签:
1条回答
  • 2020-12-06 18:06

    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

    0 讨论(0)
提交回复
热议问题