mongodbHow to use eq in MongoDB?
MongoDB's $eq
operator is used to match values that are equal to a specified value. It is part of the MongoDB query language and can be used in the find()
method.
Example
db.collection.find({ field: { $eq: value } })
This example will return all documents in the collection where the value of the field
field is equal to value
.
Code explanation
$eq
: The MongoDB operator used to match values that are equal to a specified value.find()
: The MongoDB method used to query documents in a collection.field
: The field in the document to query.value
: The value to match against the field.
Helpful links
More of Mongodb
- How to update one document in MongoDB?
- How to use watch in MongoDB?
- How to create a many to many relation in MongoDB?
- How to use transactions in MongoDB?
- How to remove a field from MongoDB?
- How to kill an operation in MongoDB?
- How to query with "not in" condition in MongoDB?
- How to insert new document into MongoDB?
- How to use MongoDB HTTP interface?
- How to perform a health check for MongoDB?
See more codes...