Tsallaka zuwa abun ciki
Justice Tech School

$expr and Computed Queries

$expr lets a query compare two fields of the same document or use aggregation expressions.

Example
db.items.find({ $expr: { $gt: ["$stock", "$minimum"] } })

Exercise

Compare two fields.

{ $: { $gt: [...] } }

Quiz Test

What can $expr compare?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.