
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10744 Articles

AmitDiwan
633 Views
For this, use aggregate() along with $unwind. Let us create a collection with documents −> db.demo583.insert([ ... { ... "details1" : [ ... { ... "details2" : [ ... ... Read More

AmitDiwan
172 Views
The accumulators are operators that maintain their state as documents progress through the pipeline.The $ROOT references the root document, i.e. the top-level document, currently being processed in the aggregation pipeline stage.Let us create a collection with documents −> db.demo582.insertOne({FirstName:"Chris", Age:21, createDate:new ISODate("2020-01-10")});{ "acknowledged" : true, "insertedId" : ObjectId("5e91ce41fd2d90c177b5bcbd") } ... Read More

AmitDiwan
299 Views
To order a list, use sort(). Let us create a collection with documents −> db.demo581.insertOne({"Name":"Chris", "Score":56});{ "acknowledged" : true, "insertedId" : ObjectId("5e91cbbbfd2d90c177b5bcb6") } > db.demo581.insertOne({"Name":"Bob", "Score":240});{ "acknowledged" : true, "insertedId" : ObjectId("5e91cbbbfd2d90c177b5bcb7") } > db.demo581.insertOne({"Name":"David", "Score":150});{ "acknowledged" : true, "insertedId" : ObjectId("5e91cbbcfd2d90c177b5bcb8") }Display all documents from a ... Read More

AmitDiwan
442 Views
To calculate the sum of unique properties in different collection elements, use $cond along with $group. This gives the resultant price.Let us create a collection with documents −> db.demo580.insertOne( ... { ... "Name":"John", ... "Id1":"110", ... "Id2":"111", ... ... Read More

AmitDiwan
348 Views
To slice only one element of array, use $slice in MongoDB. Let us create a collection with documents −> db.demo579.insertOne( ... { ... "_id" : 101, ... "details" : { "FirstName" : "John" }, ... "Marks" : [ 56, 78, ... Read More

AmitDiwan
273 Views
For this, use aggregate() along with $group. Let us create a collection with documents −> db.demo578.insertOne( ... { ... "_id" : 1, ... "Info" : { ... "firstName" : "Chris", ... "lastName" : "Brown" ... ... Read More

AmitDiwan
274 Views
To sort MongoDB collection by Array value, use aggregate() along with $sort. Let us create a collection with documents −> db.demo577.insertOne( ... { ... ... "student": { ... "details": [ ... { ... ... Read More

AmitDiwan
315 Views
Let us create a collection with documents −> db.demo576.insertOne({id:101, Name:"Chris", Marks:45}){ "acknowledged" : true, "insertedId" : ObjectId("5e916c3b581e9acd78b427fa") } > db.demo576.insertOne({id:101, Name:"John", Marks:55}){ "acknowledged" : true, "insertedId" : ObjectId("5e916c43581e9acd78b427fb") } > db.demo576.insertOne({id:101, Name:"John", Marks:65}){ "acknowledged" : true, "insertedId" : ObjectId("5e916c47581e9acd78b427fc") } > db.demo576.insertOne({id:102, Name:"David", Marks:37}){ "acknowledged" : ... Read More

AmitDiwan
625 Views
Let us create a collection with documents −> db.demo575.insertOne({id:101, Information:{Name:"Chris", Age:21}});{ "acknowledged" : true, "insertedId" : ObjectId("5e916a55581e9acd78b427f7") } > db.demo575.insertOne({id:102, Information:{Name:"David", Age:20}});{ "acknowledged" : true, "insertedId" : ObjectId("5e916a5f581e9acd78b427f8") } > db.demo575.insertOne({id:101, Information:{Name:"Bob", Age:23}});{ "acknowledged" : true, "insertedId" : ObjectId("5e916a67581e9acd78b427f9") }Display all documents from a collection with the ... Read More

AmitDiwan
531 Views
To match all the values in MongoDB, use $match along with $and in Aggregation. Let us create a collection with documents −> db.demo574.insertOne( ... { ... "details1": { ... "details2": { ... "dueDate": new ISODate("2020-01-10"), ... ... Read More