如何使用mongoid编写以下mongodb查询?
db.messages.find({
$or :[
{ $and : [
{"receiver_id":"user1@gmail.com"},
{"sender_id":"user2@hotmail.com"}
]
},
{ $and : [
{"receiver_id":"user2@hotmail.com"},
{"sender_id":"user1@gmail.com"}
]
}
]
});
答案 0 :(得分:0)
它将与:
相同Message.all.or("receiver_id":"user1@gmail.com","sender_id":"user2@hotmail.com").or("receiver_id":"user2@hotmail.com","sender_id":"user1@gmail.com")