Search⌘ K
AI Features

Solution: Using Comparison Operators

We'll cover the following...
Query
db.products.find(
{ stock: { $lte: 30 } },
{ name: 1 }
)

The explanation of the query is given below:

  • Line 1: db.products.find tells MongoDB to search the products collection and return documents that match a specific condition. The search criteria will be written inside the parentheses.

  • Line 2: stock: { $lte: 30 } is a filter condition applied to the ...