Query Operators

Comparison Operators

same syntax as before, i.e. -

{ <field> : { <operator> : <value> } }

For example, let's say from the sample_training.trips dataset, we need to find all the users that travelled for less than or equal to 70 seconds and not a subscriber. The query for the same would be

db.trips.find({"trip duration" : {"$lte": 70} }, "usertype": { "$ne": "subscriber"})

Logic Operators

db.collection_name.find(<operator>: [{condition1}, {condition2}...]
db.collection_name.find("$not": {condition})

For example, let's say we want all the documents in the inspections collection that does not have the result category of Pass, Fail, Violation Issued and No Violation Issued