0

如何用 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"}
                    ]  
                    } 
                ] 
            });
4

1 回答 1

0

It will be same as:

Message.all.or("receiver_id":"user1@gmail.com","sender_id":"user2@hotmail.com").or("receiver_id":"user2@hotmail.com","sender_id":"user1@gmail.com")
于 2013-08-19T13:35:55.607 回答