Answer the question
In order to leave comments, you need to log in
How to select data on one entity with OR operator in Mongo?
Record the progress of users who received rewards and completed tasks in monga
Task 1: Show all users who
1. Received reward X and Reward Y
AND
2. Completed task X and task Y
Task 2: Show all users who
1. Received reward X or Reward Y
AND
2. Completed task X or task Y
Guess:
rewardId in (1) and rewardId in (2) and rewardId in (3) and taskId in (1)
Answer the question
In order to leave comments, you need to log in
Received an X Award or a Y Award
Task 2: Show all users who
1. Received reward X or Award Y
AND
2. Completed task X or task Y
{$or : [{rewardId : 1}, {rewardId : 2}], $or: [ { taskId : { $eq: 1 } }, { taskId : { $eq: 2} }] }
Logical operations , $or , $and , $where , mapReduce
Complex queries can also be done like this:
db.foo.find({$where : function() { return (this.cost>5 && this.cost<10 )|| (this.is_hidden != 1) || (this.link == this.url); }})
Source
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question