Thuta Learning
IntermediateData & Databasesintermediate

Query with Filters

Relax. We'll talk through this in plain words — no textbook voice.

find() — you can filter records by passing a query filter document as its first parameter. The syntax is { <field>: <value> }.

javascript
// Find all documents where qty is 100
db.inventory.find( { qty: 100 } )
You should see
{ _id: ..., item: "paper", qty: 100, ... } { _id: ..., item: "canvas", qty: 100, ... }