collections - Meteor Multiple Field Find -
probably simple fix this, have looked through meteor documentation , couldn't find answer.
i'm trying find through collection , filter using multiple values.
in application, there 2 people in each conversation. need find if conversation exists between 2 people.
var convoexists = convo.find({ $or: [{user_1: meteor.user()._id},{user_2: userid}] }, { $or: [{user_1: userid,{user_2: meteor.user()._id}}] });
- the first parameter
.find()
query. $or
takes matrix of objects valuemeteor.user()._id
can shortenedmeteor.userid()
ex:
var convoexists = convo.find({ $or: [ { user_1: meteor.userid(), user_2: userid }, { user_1: userid, user_2: meteor.userid() } ] });
Comments
Post a Comment