I am trying to build a chat app. I have a many-to-many association. A room have many users. And a user can have many rooms. I am trying to retrieve the room which has both user A (fromUserId) and user B (toUserId). I am trying something like this but I know it's not correct:
Room.find().populate('users', { where:{ id: [fromUserId, toUserId] } }).exec(function(err, rooms){
console.log(rooms);
});
The problem here is that it returns any rooms that users.id = fromUserId or toUserId. What I need here is an and query.
Any help appreciated. (:
Aucun commentaire:
Enregistrer un commentaire