0
我想在Model上運行查詢,但只返回查詢匹配的嵌入式文檔。考慮以下...是否可以從Mongoose中的模型中僅提取嵌入式文檔?
var EventSchema = new mongoose.Schema({
typ : { type: String },
meta : { type: String }
});
var DaySchema = new mongoose.Schema({
uid: mongoose.Schema.ObjectId,
events: [EventSchema],
dateR: { type: Date, 'default': Date.now }
});
function getem() {
DayModel.find({events.typ : 'magic'}, function(err, days) {
// magic. ideally this would return a list of events rather then days
});
}
該查找操作將返回DayModel文檔的列表。但是我真正喜歡的是單獨的EventSchemas列表。這可能嗎?