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}}]      }); 

  1. the first parameter .find() query.
  2. $or takes matrix of objects value
  3. meteor.user()._id can shortened meteor.userid()

ex:

var convoexists =  convo.find({   $or: [     { user_1: meteor.userid(), user_2: userid },     { user_1: userid, user_2: meteor.userid() }   ]  }); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -