To delete an item from an object in MongoDB, use $unset. Let us create a collection with documents −> db.demo467.insertOne( ... { ... _id:101, ... "Information":{"Name":"Chris"} ... } ... ); { "acknowledged" : true, "insertedId" : 101 } > db.demo467.insertOne( ... { ... _id:102, ... "Information":{"Name":"David"} ... } ... ); { "acknowledged" : true, "insertedId" : 102 }Display all documents from a collection with the help of find() method −> db.demo467.find();This will produce the following output −{ "_id" : 101, "Information" : { "Name" : "Chris" } } { "_id" : 102, "Information" : { "Name" : "David" } }Following ... Read More
The $group in MongoDB is used to group input documents by the specified _id expression. Let us create a collection with documents −> db.demo466.insertOne( ... { ... ... "ProductPrice" :150, ... "ProductQuantity" : 1, ... "ProductName" : "Product-1", ... "ActualAmount" :110, ... "ProductProfit" : 40, ... "ProductId" : 1 ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5e80477cb0f3fa88e2279066") } > > db.demo466.insertOne( ... { ... ... "ProductPrice" :150, ... "ProductQuantity" : 1, ... "ProductName" : "Product-1", ... "ActualAmount" :110, ... "ProductProfit" : 40, ... "ProductId" : 2 ... } ... ); { "acknowledged" : true, ... Read More
For this, simply use dot notation with find() in MongoDB. Let us create a collection with documents −> db.demo465.insertOne( ... { ... id: 101, ... details: [{ ... Name: "Chris", ... Info: { ... Subject: "MongoDB", ... Marks:67 ... } ... }, { ... Name: "David", ... Info: { ... Subject: "MySQL", ... Marks:78 ... } ... ... Read More
To exclude array type field value, use delete() in MongoDB. Let us create a collection with documents −> db.demo464.insertOne( ... { ... ... "id" : "101", ... "details": [ ... { ... Name:"Chris" ... }, ... { ... Name:"David" ... } ... ] ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5e7f8832cb66ccba22cc9dda") }Display all documents from a collection with the help of find() method −> db.demo464.find();This will produce the following output −{ "_id" ... Read More
To return a single document from a collection, use findOne() in MongoDB. Let us create a collection with documents −> db.demo463.insertOne({"StudentName":"Chris Brown", "StudentAge":21, "StudentCountryName":"US"});{ "acknowledged" : true, "insertedId" : ObjectId("5e7f7ec8cb66ccba22cc9dcf") } > db.demo463.insertOne({"StudentName":"David Miller", "StudentAge":23, "StudentCountryName":"UK"});{ "acknowledged" : true, "insertedId" : ObjectId("5e7f7ed5cb66ccba22cc9dd0") } > db.demo463.insertOne({"StudentName":"John Doe", "StudentAge":22, "StudentCountryName":"AUS"});{ "acknowledged" : true, "insertedId" : ObjectId("5e7f7ee1cb66ccba22cc9dd1") } > db.demo463.insertOne({"StudentName":"John Smith", "StudentAge":24, "StudentCountryName":"US"});{ "acknowledged" : true, "insertedId" : ObjectId("5e7f7eefcb66ccba22cc9dd2") }Display all documents from a collection with the help of find() method −> db.demo463.find();This will produce the following output −{ "_id" : ObjectId("5e7f7ec8cb66ccba22cc9dcf"), "StudentName" : "Chris ... Read More
The JavaScript Symbol.toStringTag symbol is a very well known symbol that is a string valued property used for giving a description of an object during its creationFollowing is the code for Symbol.toStringTag symbol −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } div { font-size: 20px; font-weight: 500; } JavaScript Symbol.toStringTag Symbol CLICK HERE Click on the above button to get the string description for objects let fillEle = document.querySelector(".sample"); ... Read More
To update a specific document in array with $set and positional $ operator, use MongoDB updateOne(). The updateOne() updates a single document in a collection based on a query filter.Let us create a collection with documents −> db.demo462.insertOne( ... { ... "id":1, ... "DueDateDetails": [ ... { ... "Name": "David", ... "Age":21, ... "CountryName":["US", "UK"] ... }, ... { ... ... "Name": "Chris", ... "Age":23, ... ... Read More
To update tag in MongoDB, use the update command. Let us create a collection with documents −> db.demo713.insertOne( ... { ... tags: ... [ ... { ... id:101, ... Name:"Tag-1" ... }, ... { ... id:102, ... Name:"Tag-3" ... }, ... { ... id:103, ... Name:"Tag-3" ... } ... ] ... } ... ); { ... Read More
Image sprite is used to reduce the number of http requests that makes our site’s load time faster.Following is the code for creating a navigation menu using CSS image sprite −Example Live Demo body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; margin: 0px; } span { width: 200px; height: 300px; background-color: black; } nav { background-color: black; height: 50px; padding-top: 15px; padding-left: 10px; } nav a { font-size: 20px; color: white; text-decoration: none; margin-right: 10px; } .home { width: 32px; height: 32px; ... Read More
To cast to ObjectId correctly, use aggregate() in MongoDB. Let us create a collection with documents −> db.demo460.insertOne({"_id":"5ab9cbfa31c2ab715d42129e"}); { "acknowledged" : true, "insertedId" : "5ab9cbfa31c2ab715d42129e" }Display all documents from a collection with the help of find() method −> db.demo460.find();This will produce the following output −{ "_id" : "5ab9cbfa31c2ab715d42129e" }Following is the query to cast to objectId −> db.demo460.aggregate( [ idConvert ]) This will produce the following output −{ "_id" : "5ab9cbfa31c2ab715d42129e", "value" : ObjectId("5ab9cbfa31c2ab715d42129e") }
 
 Data Structure
 Data Structure Networking
 Networking RDBMS
 RDBMS Operating System
 Operating System Java
 Java MS Excel
 MS Excel iOS
 iOS HTML
 HTML CSS
 CSS Android
 Android Python
 Python C Programming
 C Programming C++
 C++ C#
 C# MongoDB
 MongoDB MySQL
 MySQL Javascript
 Javascript PHP
 PHP