Tsallaka zuwa abun ciki
Justice Tech School

Element and Type Operators

$exists tests whether a field is present and $type checks its BSON type. Use them to clean messy data.

Example
db.students.find({ phone: { $exists: false } })
db.students.find({ age: { $type: "string" } })

Exercise

Missing field.

{ phone: { $: false } }

Quiz Test

What does $exists check?

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