- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1659 Articles for Big Data Analytics
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
121 Views
To find a MongoDB document through a word, use find() and set the word like −word/iLet us create a collection with documents −> db.demo212.insertOne({"details":[{"Name":"John Doe"}]}); { "acknowledged" : true, "insertedId" : ObjectId("5e3e2c7603d395bdc21346ff") } > db.demo212.insertOne({"details":[{"Name":"Chris Brown"}]}); { "acknowledged" : true, "insertedId" : ObjectId("5e3e2c8003d395bdc2134700") } > db.demo212.insertOne({"details":[{"Name":"Robert doe"}]}); { "acknowledged" : true, "insertedId" : ObjectId("5e3e2c8a03d395bdc2134701") }Display all documents from a collection with the help of find() method −> db.demo212.find();This will produce the following output −{ "_id" : ObjectId("5e3e2c7603d395bdc21346ff"), "details" : [ { "Name" : "John Doe" } ] } { "_id" : ObjectId("5e3e2c8003d395bdc2134700"), "details" : ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
55 Views
To test the values, use $type. Let us create a collection with documents −> db.demo211.insertOne({id:101, "Name":"Chris"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3e298203d395bdc21346fa") } > db.demo211.insertOne({id:102, "Name":null}); { "acknowledged" : true, "insertedId" : ObjectId("5e3e2a5403d395bdc21346fb") }Display all documents from a collection with the help of find() method −> db.demo211.find();This will produce the following output −{ "_id" : ObjectId("5e3e298203d395bdc21346fa"), "id" : 101, "Name" : "Chris" } { "_id" : ObjectId("5e3e2a5403d395bdc21346fb"), "id" : 102, "Name" : null }Following is the query to test if two external values are equal in a MongoDB criteria object −> v1=200; 200 > v2=200; ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
349 Views
To get the count of a specific value in MongoDB, use aggregate(). Let us create a collection with documents −> db.demo210.insertOne( ... { ... details: [ ... { ... ClientName: "Robert" ... }, ... { ... ... lientName: "John Doe" ... }, ... { ... ... ClientName: "Robert" ... }, ... { ... ... ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
223 Views
To convert filed value to create datetime day of month, use MongoDB aggregate(). Let us create a collection with documents −> db.demo209.insertOne( ... { ... "_id" : "101", ... "details" : [ ... { ... "dat" : 1528929908, ... "Name" : "Chris" ... }, ... { ... "dat" : 1529082069, ... "Name":"Carol" ... } ... ], ... ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
506 Views
To convert numeric string to number, use parseInt() in MongoDB. Let us create a collection with documents −> db.demo208.insertOne( { "value":"50"} ); { "acknowledged" : true, "insertedId" : ObjectId("5e3d92d803d395bdc21346f6") } > db.demo208.insertOne( { "value":"2350"} ); { "acknowledged" : true, "insertedId" : ObjectId("5e3d92dd03d395bdc21346f7") }Display all documents from a collection with the help of find() method −> db.demo208.find();This will produce the following output −{ "_id" : ObjectId("5e3d92d803d395bdc21346f6"), "value" : "50" } { "_id" : ObjectId("5e3d92dd03d395bdc21346f7"), "value" : "2350" }Following is the query to convert numeric string to number −> db.demo208.find().forEach( function (doc) { ... doc.value = parseInt(doc.value); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
265 Views
Take the help of $addToSet in MongoDB to specify a return format. Let us create a collection with documents −> db.demo207.insertOne({"FavouriteTechnology":"Spring Boot"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3d8e7a03d395bdc21346f1") } > db.demo207.insertOne({"FavouriteTechnology":"MongoDB"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3d8e8f03d395bdc21346f2") } > db.demo207.insertOne({"FavouriteTechnology":"Groovy"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3d8ea603d395bdc21346f3") }Display all documents from a collection with the help of find() method −> db.demo207.find();This will produce the following output −{ "_id" : ObjectId("5e3d8e7a03d395bdc21346f1"), "FavouriteTechnology" : "Spring Boot" } { "_id" : ObjectId("5e3d8e8f03d395bdc21346f2"), "FavouriteTechnology" : "MongoDB" } { "_id" : ObjectId("5e3d8ea603d395bdc21346f3"), "FavouriteTechnology" : "Groovy" }Following is ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
258 Views
To determine if a specific value does not exist, use $ne in MongoDB. Let us create a collection with documents −> db.demo206.insertOne( ... { ... "ClientDetails": ... [ ... { ... "Name":"Chris", ... "Age":28, ... "CountryName":"US" ... } ... ] ... } ...); { "acknowledged" : true, "insertedId" : ObjectId("5e3d8bd403d395bdc21346ee") } > db.demo206.insertOne( ... { ... "ClientDetails": ... [ ... ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
505 Views
To count records on the basis of matching criteria, use count(). Let us create a collection with documents −> db.demo205.insertOne( ... { ... ... "id": "101", ... "Name": "", ... "Age": "", ... "isActive": false ... } ...); { "acknowledged" : true, "insertedId" : ObjectId("5e3d8a3003d395bdc21346eb") } > db.demo205.insertOne( ... { ... ... "id": "102", ... "Name": "Chris", ... "Age": "25", ... "isActive": true ... } ...); { "acknowledged" : true, "insertedId" : ObjectId("5e3d8a3003d395bdc21346ec") } > db.demo205.insertOne( ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
242 Views
To display only an element found in an array, use aggregate(). Let us create a collection with documents −> db.demo204.insertOne( ... { ... "_id" : 101, ... "Name" : "Chris", ... "Age" : 23, ... "details" : [ ... { ... "id" : "1001", ... "empId" : "John_1001", ... "salary" : "50000", ... "Technology" : "Java" ... }, ... ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
635 Views
To query nested array, use $elemMatch in MongoDB. Let us create a collection with documents −> db.demo203.insertOne({ ... "_id" : "101", ... "Name" : "Chris", ... "details1" : [ ... { ... "empName" : "David", ... "salary" : "50000", ... "technology" : [ ... "MySQL", ... "MongoDB" ... ] ... }, ... { ... "empName" : "Carol", ... ... Read More