$eq
The $eq operator in Amazon DocumentDB is used to match documents where the value of a field is equal to the specified value. This operator is commonly used in the find() method to retrieve documents that meet the specified criteria.
Parameters
-
field: The field to check for the equality condition. -
value: The value to compare against the field.
Example (MongoDB Shell)
The following example demonstrates the usage of the $eq operator to find all documents where the name field is equal to "Thai Curry Palace".
Create sample documents
db.restaurants.insertMany([ { name: "Thai Curry Palace", cuisine: "Thai", features: ["Private Dining"] }, { name: "Italian Bistro", cuisine: "Italian", features: ["Outdoor Seating"] }, { name: "Mexican Grill", cuisine: "Mexican", features: ["Takeout"] } ]);
Query example
db.restaurants.find({ name: { $eq: "Thai Curry Palace" } });
Output
{ "_id" : ObjectId("68ee586f916df9d39f3d9414"), "name" : "Thai Curry Palace", "cuisine" : "Thai", "features" : [ "Private Dining" ] }
Code examples
To view a code example for using the $eq command, choose the tab for the language that you want to use: