MongoDB challenges

Practice problem statements with input format, output format, constraints and solutions.

beginner

MongoDB Introduction challenge

Build a small solution that uses MongoDB Introduction in MongoDB and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

db.orders.find({
  status: "paid",
  total: { $gte: 50 }
}).sort({ total: -1 })

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core mongodb introduction pattern before polishing the final output.

Solution

db.orders.find({
  status: "paid",
  total: { $gte: 50 }
}).sort({ total: -1 })
beginner

Database challenge

Build a small solution that uses Database in MongoDB and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

db.orders.find({
  status: "paid",
  total: { $gte: 51 }
}).sort({ total: -1 })

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core database pattern before polishing the final output.

Solution

db.orders.find({
  status: "paid",
  total: { $gte: 51 }
}).sort({ total: -1 })
beginner

Collection challenge

Build a small solution that uses Collection in MongoDB and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

db.orders.find({
  status: "paid",
  total: { $gte: 52 }
}).sort({ total: -1 })

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core collection pattern before polishing the final output.

Solution

db.orders.find({
  status: "paid",
  total: { $gte: 52 }
}).sort({ total: -1 })
beginner

Document challenge

Build a small solution that uses Document in MongoDB and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

db.orders.find({
  status: "paid",
  total: { $gte: 53 }
}).sort({ total: -1 })

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core document pattern before polishing the final output.

Solution

db.orders.find({
  status: "paid",
  total: { $gte: 53 }
}).sort({ total: -1 })
beginner

Insert challenge

Build a small solution that uses Insert in MongoDB and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

db.orders.find({
  status: "paid",
  total: { $gte: 54 }
}).sort({ total: -1 })

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core insert pattern before polishing the final output.

Solution

db.orders.find({
  status: "paid",
  total: { $gte: 54 }
}).sort({ total: -1 })
beginner

Find challenge

Build a small solution that uses Find in MongoDB and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

db.orders.find({
  status: "paid",
  total: { $gte: 55 }
}).sort({ total: -1 })

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core find pattern before polishing the final output.

Solution

db.orders.find({
  status: "paid",
  total: { $gte: 55 }
}).sort({ total: -1 })
beginner

Update challenge

Build a small solution that uses Update in MongoDB and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

db.orders.find({
  status: "paid",
  total: { $gte: 56 }
}).sort({ total: -1 })

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core update pattern before polishing the final output.

Solution

db.orders.find({
  status: "paid",
  total: { $gte: 56 }
}).sort({ total: -1 })
beginner

Delete challenge

Build a small solution that uses Delete in MongoDB and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

db.orders.find({
  status: "paid",
  total: { $gte: 57 }
}).sort({ total: -1 })

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core delete pattern before polishing the final output.

Solution

db.orders.find({
  status: "paid",
  total: { $gte: 57 }
}).sort({ total: -1 })
beginner

Filters challenge

Build a small solution that uses Filters in MongoDB and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

db.orders.find({
  status: "paid",
  total: { $gte: 58 }
}).sort({ total: -1 })

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core filters pattern before polishing the final output.

Solution

db.orders.find({
  status: "paid",
  total: { $gte: 58 }
}).sort({ total: -1 })
beginner

Sorting challenge

Build a small solution that uses Sorting in MongoDB and handles one normal case plus one edge case.

Input format

Use a short text value, array, query, or sample object depending on the topic.

Output format

Print, render, or return the processed result in a readable format.

Constraints

  • Keep the solution under 60 lines.
  • Use descriptive names.
  • Do not depend on hidden external services.

Starter code

db.orders.find({
  status: "paid",
  total: { $gte: 59 }
}).sort({ total: -1 })

Test cases

  • basic sample - valid processed result
  • empty or small sample - safe fallback result

Hint

Focus on the core sorting pattern before polishing the final output.

Solution

db.orders.find({
  status: "paid",
  total: { $gte: 59 }
}).sort({ total: -1 })