There are 2 methods in MongoDB find.
- find()
- findOne()
1. find()-
Select date in collection you used find().
Syntex-
db.collection.find({ <criteria> })Example- Find all documents in the "users" collection where the age is 30
db.users.find({ age: 30 })2. findOne()-
Get only one document, You can use the findOne() method.
Syntex-
db.collection.findOne({ <criteria> })Operators:
| Operator | Purpose |
| --------- | ------------------------- |
| `$eq` | Equal |
| `$ne` | Not Equal |
| `$gt` | Greater Than |
| `$gte` | Greater Than or Equal |
| `$lt` | Less Than |
| `$lte` | Less Than or Equal |
| `$in` | Match any value in a list |
| `$nin` | Not in list |
| `$and` | AND condition |
| `$or` | OR condition |
| `$exists` | Field exists |
| `$regex` | Pattern matching |
| `$set` | Update/add field |
| `$unset` | Remove field |
| `$inc` | Increment value |
| `$push` | Add to array |
| `$pull` | Remove from array |