
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
2K+ Views
To fetch a specific element, iterate with forEach(). Let us create a collection with documents −> db.demo742.insertOne({ "userDetails": [ { "userName":"Robert", "CountryName":"UK" }, { "userName":"David", "CountryName":"AUS" } ]} ); { "acknowledged" : true, "insertedId" : ObjectId("5ead790b57bb72a10bcf0677") }Display all documents from a collection with the help of find() method ... Read More

AmitDiwan
145 Views
To update for _id, use $set in MongoDB. Let us create a collection with documents −db.demo741.insertOne({SubjectName:"MySQL"}); { "acknowledged" : true, "insertedId" : ObjectId("5ead718657bb72a10bcf0672") } > db.demo741.insertOne({SubjectName:"C"}); { "acknowledged" : true, "insertedId" : ObjectId("5ead718957bb72a10bcf0673") } > db.demo741.insertOne({SubjectName:"Java"}); { "acknowledged" : true, "insertedId" : ObjectId("5ead718e57bb72a10bcf0674") }Display ... Read More

AmitDiwan
574 Views
Let us create a collection with documents −> db.demo740.insertOne({ ... "details": ... [ ... { ... Name:"Chris", ... Age:21, ... CountryName:"US" ... }, ... { ... ... Read More

AmitDiwan
1K+ Views
To push value, use save() along with for loop. Let us create a collection with documents −> for(var v=1; v db.demo739.find();This will produce the following output −{ "_id" : ObjectId("5ead6e7857bb72a10bcf0666"), "Name" : "Chris", "SubjectName" : "MongoDB" } { "_id" : ObjectId("5ead6e7857bb72a10bcf0667"), "Name" : "Chris", "SubjectName" : "MongoDB" } { "_id" ... Read More

AmitDiwan
219 Views
Let us create a collection with documents −> db.demo738.insertOne({Subjects:["C", "C++"]}); { "acknowledged" : true, "insertedId" : ObjectId("5ead696557bb72a10bcf0661") } > db.demo738.insertOne({Subjects:["MySQL", "PL/SQL"]}); { "acknowledged" : true, "insertedId" : ObjectId("5ead696657bb72a10bcf0662") }Display all documents from a collection with the help of find() method −> db.demo738.find();This will produce the following ... Read More

AmitDiwan
2K+ Views
To order by timestamp, use sort() in MongoDB. Let us create a collection with documents −> db.demo737.insertOne({"timestamp" : new ISODate("2020-04-01" )}); { "acknowledged" : true, "insertedId" : ObjectId("5ead682157bb72a10bcf065c") } > db.demo737.insertOne({"timestamp" : new ISODate("2020-10-31" )}); { "acknowledged" : true, "insertedId" : ObjectId("5ead682757bb72a10bcf065d") } > db.demo737.insertOne({"timestamp" : ... Read More

AmitDiwan
342 Views
For this, use aggregate() in MongoDB. Let us create a collection with documents −> db.demo736.insertOne( ... { ... "_id": "101", ... "details1": [ ... { ... "details2": [ ... ... Read More

AmitDiwan
1K+ Views
MongoDB insertOne() inserts a document into a collection, whereas updateOne() update a single document in a collection based on a query filter.Let us create a collection with documents −> db.demo735.insertOne({id:1, Name:"Chris"}); { "acknowledged" : true, "insertedId" : ObjectId("5ead51b657bb72a10bcf0652") } > db.demo735.insertOne({id:1, Name:"David"}); { "acknowledged" : true, ... Read More

AmitDiwan
1K+ Views
To get the difference between dates in MongpDB, use aggregate(). Let us create a collection with documents −> db.demo734.insertOne({GivenDate:new ISODate("2020-01-10")}); { "acknowledged" : true, "insertedId" : ObjectId("5ead4f1a57bb72a10bcf064e") } > db.demo734.insertOne({GivenDate:new ISODate("2020-02-20")}); { "acknowledged" : true, "insertedId" : ObjectId("5ead4f2157bb72a10bcf064f") } > db.demo734.insertOne({GivenDate:new ISODate("2010-12-01")}); { "acknowledged" : ... Read More

AmitDiwan
627 Views
The HTML DO MouseEvent offsetX property returns the horizontal (x) coordinate of the mouse pointer relative to the target element if a mouse event was triggered. Use with offsetY to get the vertical coordinate as well.Following is the syntax −Returning reference to the offsetX objectMouseEventObject.offsetXLet us see an example of MouseEvent offsetX ... Read More