我有2个架构 . 命名用户和朋友 .

用户架构如下:

var userSchema = mongoose.Schema({
    first_name: {type: String},
    last_name: {type: String},
    update_at: {type: Date}
})

Friends Schema如下:

var userfollowersSchema = mongoose.Schema({
    user_id: {type: String, ref: '"'User'"'},
    friends_id: {type: String, ref: 'User'}
})

我正在使用以下查询填充朋友ID . Mongoose

.populate('friends_id', '_id update_at', null, {sort: { 'update_at': -1 } })

我也尝试过:

.populate({
    path: 'friends_id',
    select: ('_id update_at'),
    options: {
        sort: '-following_id.update_at'
    }
})

但它与_id合作 . 我得到了结果:

[{
    friends_id: {
        update_at: Fri May 13 2016 15:46:43 GMT+0530 (India Standard Time),
        count: 1,
        _id: 5735a23168264e700b17e6ee
    },
    _id: 5735a2bb68264e700b17e6f2
}, {
    friends_id: {
        update_at: Fri May 13 2016 15:47:31 GMT+0530 (India Standard Time),
        count: 0,
        _id: 5735a24168264e700b17e6ef
    },
    _id: 5735a2c068264e700b17e6f3
}, {
    friends_id: {
        update_at: Fri May 13 2016 18:47:13 GMT+0530 (India Standard Time),
        count: 2,
        _id: 5735a25868264e700b17e6f0
    },
    _id: 5735a2c568264e700b17e6f4
}]

问:如何按时间对填充结果进行排序?猫鼬版 -

'''mongoose'“':'''^ 4.4.6'”',