12

The values for the key is_agent is TRUE or blank.

I have the following query:

db.users.find( { $not: {is_agent:TRUE} }, {email:1} )

I get the following error:

ReferenceError: TRUE is not defined

When I used "TRUE" I got the following error:

"$err" : "Can't canonicalize query: BadValue unknown top level operator: $not",
"code" : 17287

What is the correct syntax?

1 Answer 1

22

$eq Matches values that are equal to a specified value.

$ne Matches all values that are not equal to a specified value.

Documentation on mongodb operators

Example:

db.users.find({is_agent: {$ne: true}})

or

db.users.find({is_agent: {$eq: true}})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.