mongoose "Find" with multiple conditions

Created At: 2024-05-08 08:42:07 Updated At: 2024-05-09 16:13:25

Here we will see how to use Find() in mongoose with multiple conditions like AND or OR. It's like matching more conditions.

Here we want to add more conditions. As you can see paymentStatus is 'Completed'. But I wanted to add something that is 'Pending'.

So whether the orders are pending or completed, I want to select all of them.

To do that we need to introduce a new variable $or and write like below

Here I have used $or variable to get all the results. You may use $and variable common data. You also need to see how we wrap this around [] and {}. 

That means you can add multiple conditions within the statement.

Comment

Add Reviews