</>
Skip to content
MongoDB lessons (10/38)

MongoDB — Find

Basic Find

db.users.find()
db.users.find({ name: "John" })
db.users.findOne({ name: "John" })

Comparison Operators

OperatorDescription
$eqEqual
$neNot equal
$gtGreater than
$gteGreater or equal
$ltLess than
$lteLess or equal
$inIn array
$ninNot in array

Examples

// Greater than
db.users.find({ age: { $gt: 25 } })

// In array
db.users.find({ country: { $in: ["USA", "UK"] } })

// Range
db.users.find({ age: { $gte: 18, $lte: 30 } })

Projection

// Include fields
db.users.find({}, { name: 1, email: 1 })

// Exclude fields
db.users.find({}, { password: 0 })

Limit and Skip

db.users.find().limit(10)
db.users.find().skip(10).limit(10)

Sort

db.users.find().sort({ name: 1 })  // Ascending
db.users.find().sort({ name: -1 }) // Descending

Mini Practice

  1. Find all documents
  2. Find with conditions
  3. Use projection
  4. Sort and limit results

Up Next

Continue with Query — advanced queries.

Related Topics

Frequently Asked Questions about Find

What is Find in MongoDB?

Find is a fundamental concept in MongoDB. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Find?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Find.

Why is Find important in MongoDB?

Find is essential for MongoDB development. Understanding this concept will help you write better code and solve real-world problems more effectively.