MongoDB find() Method (original) (raw)

Last Updated : 5 May, 2026

The find() method retrieves documents from a MongoDB collection, supporting query filters, field projection, and query options to customize results while leveraging available indexes for efficient performance.

**Syntax

db.collection_name.find(selection_criteria, projection,options)

Examples of find() Method

Consider a collection called studentofgfg database which contains the following documents:

Example 1: Find All Documents in a Collection

Find all student records from the "students" collection.

db.students.find()

**Output:

Screenshot-2026-02-06-142321

Example 2: Find Documents with a Specific Condition

Find all the students whose age is exactly 18.

db.students.find({age:18})

**Output:

Screenshot-2026-02-06-142408

Example 3: Using Nested Documents in Queries

Find student records from the "students" collection where the student's mathscore is 230and sciencescore is 234.

db.students.find({score:{math: 230, science: 234}})

**Output:

Screenshot-2026-02-06-142635

Example 4: Using Projection

Retrieve the names of all students while excluding the score field.

db.students.find({}, {score: 0 })

**Output:

Screenshot-2026-02-06-143143

Example 5: Sorting Results

Retrieve all student records sorted by age in ascending order.

db.students.find().sort({ age: 1 })

**Output:

Screenshot-2026-02-06-143406

Example 6: Limiting Results

The limit method restricts the number of documents returned to the specified value.

db.students.find().limit(2)

**Output:

Screenshot-2026-02-06-143558