The MongoDB query operator is used when we require to perform complex operations or elaborate queries that cannot be handled through simple methods. MongoDB provides several types of query operators such as comparison, logical, element, array, bitwise, etc.
Here is a general syntax for using MongoDB Query Operators :
`db.collection.find({field: {operator: value}})`
Below are some examples of MongoDB query operators:
1. Comparison Operator:
Comparison operators allow users to compare the specified value with the field value of a document:
```
db.students.find({marks: {$eq: 50}})
```
This will return all documents in the ‘students’ collection where ‘marks’ is equal to 50.
1. Logical Operator:
Logical operators are used to combine multiple conditions:
```
db.students.find({$or: [{age: 18}, {name: ‘John’}]})
```
This will return all documents from the ‘students’ collection where ‘age’ is 18 or ‘name’ is ‘John’.
1. Element Operator:
Element operators are used to check if a field exists or if a field is of a certain type:
```
db.students.find({age: {$exists: true}})
```
This will return all documents from the ‘students’ collection where the ‘age’ field exists.
1. Array Operator:
Array operators are used to query arrays:
```
db.students.find({marks: {$in: [50, 60, 70]}})
```
This will return all documents from the ‘students’ collection where ‘marks’ is either 50, 60, or 70.
1. Bitwise Operator:
Bitwise operators are used for bitwise operations in queries:
```
db.students.find({ age: { $bitsAllSet: 5 } });
```
This will return all documents from the ‘students’ collection where the ‘age’ field has bits set in the bit positions specified by the number 5.
Please replace `students` with your collection name and `age`, `marks`, etc with your field names to work properly.
Note: You can use these query operators in your CRUD operations as well. For Example, in update operation :
```
db.students.updateOne({ name: ‘John’ }, { $set: { age: 20 } })
```
This command will update the ‘age’ to 20 of the first document in the ‘students’ collection where the ‘name’ is ‘John’.