表结构如下:
var AdviceSchema = new Schema({
_id: Number
, replyTo: Number //回复的id
, from: Number //发送消息的userId
, to: Number //接受消息的userId
, content: String
, dateCreated: {type: Date, default: Date.now}
});
var Advice = mongoose.model('Advice', AdviceSchema);
//现在要查询从userId为1发起给userId为2的所有advice
Advice.find({
from: 1
, to: 2
}, next);
//但还需要获取从userId为2发起给userId为1的 回复advice
//能够在db查询中搞定么,我不想循环查询。。。