如何使用猫鼬从子文档数组中查找最新的数组元素?

时间:2019-06-01 00:15:56

标签: angularjs mongoose angularjs-directive mongoose-schema mongoose-populate

我的架构定义如下:

var nSchema = new Schema({
    message: String,
    creationDate: { type : Date, default: Date.now }
});

var sSchema = new Schema({
    _id: {type:ObjectId, auto: true },
    dataId: { type:String, unique: true },
    notes: [nSchema]
}

对于每个dataId,可以有多个notes []条目。

我正在编写一个从message中查找最新notes[]的函数。根据{{​​1}}

确定最新消息
creationDate

0 个答案:

没有答案
相关问题