How to make query "or" instead of "and"?

Users can filter cards based on what kind of filter they select.
But currently instead of “or”, I get a result as ‘and’.

Here is an example.

{
  '_id':'111111111111',
  'title':'This is a title',
  'description': 'Description',
  assigned:true,
  leader:false,
  public:true
}

{
  '_id':'222222222222',
  'title':'apple',
  'description': 'banana',
  assigned : false,
  leader : false,
  public : true
}

{
  '_id':'33333333333333',
  'title':'lemon',
  'description': 'hello',
  assigned:false,
  leader:true,
  public:false
}

And user wants to get cards that have assigned: true OR leader: false which this case _id : ''111111111111" and _id : "33333333333333".

What would be the query for this look like?

When I console my query it looks like this and this will fetch cards that have assigned: true AND leader: false.

{
	assigned: true,
	leader: false
}

Use the $or operator

db.collectionNameGoesHere.find( { $or: [ { assigned: { true } }, { leader: false } ] } )

2 Likes