0

I want to select all the records that meet below criteria:

if "used1" not in record or record["used1"] != True

How to write this? Thanks.

1 Answer 1

3

You'd use $exists for the first:

db.collection.find({ used1: { $exists: false } })

and $ne for the second:

db.collection.find({ used1: { $ne: true } })

To combine them, use $or:

db.collection.find({
    $or: [
        { used1: { $exists: false } },
        { used1: { $ne:     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.