Reputation: 63349
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.
Upvotes: 0
Views: 198
Reputation: 434745
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 } }
]
})
Upvotes: 3