
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
Write an equality in MongoDB without using $eq operator
Let us first create a collection with documents -
> db.operatorDemo.insertOne({"StudentSubject":["MongoDB","MySQL","Java"]}); { "acknowledged" : true, "insertedId" : ObjectId("5cef94eaef71edecf6a1f6a2") } > db.operatorDemo.insertOne({"StudentSubject":["Java","C","C++"]}); { "acknowledged" : true, "insertedId" : ObjectId("5cef94faef71edecf6a1f6a3") }
Display all documents from a collection with the help of find() method -
> db.operatorDemo.find().pretty();
Output
{ "_id" : ObjectId("5cef94eaef71edecf6a1f6a2"), "StudentSubject" : [ "MongoDB", "MySQL", "Java" ] } { "_id" : ObjectId("5cef94faef71edecf6a1f6a3"), "StudentSubject" : [ "Java", "C", "C++" ] }
Following is the query for an equality without $eq operator:
> db.operatorDemo.find({StudentSubject:"MongoDB"});
Output
{ "_id" : ObjectId("5cef94eaef71edecf6a1f6a2"), "StudentSubject" : [ "MongoDB", "MySQL", "Java" ] }
- Related Articles
- Alternative of MongoDB operator $eq to get similar result
- Find the exact match in array without using the $elemMatch operator in MongoDB?
- Division without using ‘/’ operator in C++ Program
- Using positional operator with hierarchies in MongoDB?
- MongoDB aggregation with equality inside array?
- How do we use equivalence (“equality”) operator in Python classes?
- Multiples of 3 and 5 without using % operator in C++
- How to query MongoDB using the $ne operator?
- Find largest element from array without using conditional operator in C++
- Program to find remainder without using modulo or % operator in C++
- Find XOR of two number without using XOR operator in C++
- Match ID and fetch documents with $eq in MongoDB in case of array?
- Divide two integers without using multiplication, division and mod operator
- Java Program to Add two Numbers without using Arithmetic Operator
- Maximum of four numbers without using conditional or bitwise operator in C++

Advertisements