
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
263 Views
To implement $dateToString on array items, use aggregate() in MongoDB. Let us create a collection with documents −> db.demo104.insertOne( ... { ... ... "AppName" : "Online Book", ... "Details" : [ ... { ... ... Read More

AmitDiwan
850 Views
To query on the last object of an array, use aggregate(). Let us create a collection with documents −> db.demo103.insertOne( { "Details" : [ { "StudentId" : 101, "Details" : "MongoDB" }, {"StudentId" : 102, "Details" : "MySQL" }, { "StudentId" : 103, "Details" : "Java" } ... Read More

AmitDiwan
597 Views
For this, create two collections and add some document. After that, use $lookup for match. Let us create a collection with documents −> db.demo101.insertOne( ... { "_id" : "1", "Details" : [ { "PId" : "200" }, { "PId" : "201" }, { "PId" : "201" } ] } ... ... Read More

AmitDiwan
176 Views
To fetch documents except a specific document, set the document to be missed using the $nor in MongoDB. Let us create a collection with documents −> db.demo100.insertOne({"Name":"Chris", "Age":21}); { "acknowledged" : true, "insertedId" : ObjectId("5e2d9624b8903cdd865577c0") } > db.demo100.insertOne({"Name":"David", "Age":23}); { "acknowledged" : true, "insertedId" : ObjectId("5e2d962cb8903cdd865577c1") ... Read More

AmitDiwan
1K+ Views
At first, let us create a collection with documents −> db.demo99.insertOne( ... { ... ... 'Details': ... { ... 'X': ... { ... 'Values': [10, 30, 50], ... ... Read More

AmitDiwan
526 Views
To increment a property value of an element, use update() in MongoDB and in that, work with #$inc to increment. Let us first create a collection with documents −> db.demo97.insertOne({ ... "Details": [ ... { ... "Name": "Chris", ... ... Read More

AmitDiwan
3K+ Views
To find sum of fields inside array, use $sum. Let us create a collection with documents −> db.demo96.insertOne( ... { ... ... "Name" : "Chris", ... "Details" : [ ... { ... Marks:67 ... }, ... ... Read More

AmitDiwan
4K+ Views
To convert string to objectid in MongoDB, use $toObjectId. Let us create a collection with documents −> db.demo95.insertOne({"Id":"5ab9cbe531c2ab715d42129a"}); { "acknowledged" : true, "insertedId" : ObjectId("5e2d5ef5b8903cdd865577ac") }Display all documents from a collection with the help of find() method −> db.demo95.find();This will produce the following output −{ "_id" : ObjectId("5e2d5ef5b8903cdd865577ac"), ... Read More

AmitDiwan
739 Views
To update array with multiple conditions, use $push in MongoDB. Let us create a collection with documents −> db.demo94.insertOne( ... { ... ... "Details" : [ ... { ... "Name" : "Chris", ... "Subject" : [] ... ... Read More

AmitDiwan
2K+ Views
To convert date to timestamp in MongoDB, use aggregate(). Let us create a collection with documents −> db.demo93.insertOne({"UserName":"Chris", "ArrivalDate":new ISODate("2020-10-01")}); { "acknowledged" : true, "insertedId" : ObjectId("5e2d4b6479799acab037af68") } > db.demo93.insertOne({"UserName":"David", "ArrivalDate":new ISODate("2019-12-31")}); { "acknowledged" : true, "insertedId" : ObjectId("5e2d4b7379799acab037af69") }Display all documents from a collection with ... Read More