有如下两个Model
(1)用户Model
var usersSchema = new Schema({
f_id: {
unique: true,
type: String
},
f_name: String
})
(2)记录Model
var batchMainSchema = new Schema({
f_id: {
unique: true,
type: String
},
f_user_log: [{
f_option: String,
f_time: Date,
f_user_model: { type: Schema.Types.ObjectId, ref: "users" },
}]
})
需要在记录Model中的f_user_log字段中保存用户操作记录
请问这种写法能不能在查询记录数据时获取到f_user_model的值
如下图中的写法不能获取到想要的用户信息
请问大伙有没有相应的解决办法,谢谢!!!
populate
做不到,用aggregate
。