我在mongodb中有以下两个模式
var userSchema = new Schema({
first_name: String,
last_name: String,
email: String
});
var messageSchema = new Schema({
sender: {type: Schema.Types.ObjectId, ref: 'users' },
receiver: {type: Schema.Types.ObjectId, ref: 'users' },
message: String,
sentOn: Date,
});
var Users = mongoose.model('users', userSchema);
var Messages = mongoose.model('messages', messageSchema);
如何查询来自'用户'的所有用户?收集和他们的最后一条消息(单个)来自'消息'集合?