- 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
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
3K+ Views
Use operator $gte and $lt to find objects between two dates in MongoDB. To understand these operators, let us create a collection.Creating a collection here:>db.order.insert({"OrderId":1, "OrderAddrees":"US", "OrderDateTime":ISODate("2019-02-19")}; WriteResult({ "nInserted" : 1 }) >db.order.insert({"OrderId":2, "OrderAddrees":"UK", "OrderDateTime":ISODate("2019-02-26")}; WriteResult({ "nInserted" : 1 })Display all documents from the collection with the help of find() method. The query is as follows:> db.order.find().pretty();The following is the output:{ "_id" : ObjectId("5c6c072068174aae23f5ef57"), "OrderId" : 1, "OrderAddrees" : "US", "OrderDateTime" : ISODate("2019-02-19T00:00:00Z") } { "_id" : ObjectId("5c6c073568174aae23f5ef58"), "OrderId" : 2, "OrderAddrees" : "UK", "OrderDateTime" : ISODate("2019-02-26T00:00:00Z") }Here is the query ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
2K+ Views
You can use aggregate function to update MongoDB field using the value of another field. Here, we will create two collections:namestudentInformation CollectionThe query to create first collection with documents is as follows:> db.name.insert({"FirstName":"John", "LastName":"Smith"}); WriteResult({ "nInserted" : 1 })Now you can display all documents from the collection with the help of find() method. The query is as follows:> db.name.find().pretty();The following is the output that displays the collection “name” documents:{ "_id" : ObjectId("5c6c00dd68174aae23f5ef55"), "FirstName" : "John", "LastName" : "Smith" } CollectionThe query to create second collection with documents is as follows:> db.studentInformation.insert({"StudentFirstName":"Carol", "StudentLastName":"Taylor"}); WriteResult({ "nInserted" : 1 })Now ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
237 Views
You can use projection operator $elemMatch to filter in queried element in an object array in MongoDB collection. To retrieve only the queried element in an object array in MongoDB, let us first create a collection with documents object array.The query is as follows:> db.objectArray.insert({"Persons":[ {"PersonName":"Adam", "PersonSalary":25000}, {"PersonName":"Larry", "PersonSalary":27000 }]}); WriteResult({ "nInserted" : 1 }) > db.objectArray.insert({"Persons":[ {"PersonName":"David", "PersonSalary":32000}, {"PersonName":"Carol", "PersonSalary":77000 }]}); WriteResult({ "nInserted" : 1 })Now you can display all the documents with the help of find(). The query is as follows:> db.objectArray.find().pretty();The following is the output:{ "_id" : ObjectId("5c6bfadc68174aae23f5ef53"), "Persons" ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
1K+ Views
To retrieve documents from a collection in MongoDB, you need to use find() method. The syntax is as follows:db.yourCollectionName.find();The above syntax will return all the documents from a collection in MongoDB. To understand the above syntax, let us create a collection with documents. The query to create documents are as follows:> db.retrieveAllStudents.insertOne({"StudentId":"STUD101", "StudentName":"David", "StudentAge":24}); { "acknowledged" : true, "insertedId" : ObjectId("5c6bf5cf68174aae23f5ef4e") } > db.retrieveAllStudents.insertOne({"StudentId":"STUD102", "StudentName":"Carol", "StudentAge":22}); { "acknowledged" : true, "insertedId" : ObjectId("5c6bf5e968174aae23f5ef4f") } > db.retrieveAllStudents.insertOne({"StudentId":"STUD103", "StudentName":"Maxwell", "StudentAge":25}); { "acknowledged" : true, "insertedId" : ObjectId("5c6bf5f768174aae23f5ef50") } > db.retrieveAllStudents.insertOne({"StudentId":"STUD104", "StudentName":"Bob", "StudentAge":23}); { "acknowledged" : true, "insertedId" : ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
556 Views
If you want to delete all documents from the collection, you can use deleteMany(). Let us first create a collection and insert some documents to it:> db.deleteDocumentsDemo.insert({"Name":"Larry", "Age":23}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Mike", "Age":21}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Sam", "Age":24}); WriteResult({ "nInserted" : 1 })Now display all the documents from the collection. The query is as follows:> db.deleteDocumentsDemo.find().pretty();The following is the output:{ "_id" : ObjectId("5c6ab0e064f3d70fcc914805"), "Name" : "Larry", "Age" : 23 } { "_id" : ObjectId("5c6ab0ef64f3d70fcc914806"), "Name" : "Mike", "Age" : 21 } { "_id" : ObjectId("5c6ab0f864f3d70fcc914807"), "Name" ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
238 Views
To delete document from a collection in MongoDB, you can use the deleteOne() method. Let us first create a collection and insert some documents to it:> db.deleteDocumentsDemo.insert({"Name":"Larry", "Age":23}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Mike", "Age":21}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Sam", "Age":24}); WriteResult({ "nInserted" : 1 })Now display all the documents from the collection. The query is as follows:> db.deleteDocumentsDemo.find().pretty();The following is the output:{ "_id" : ObjectId("5c6ab0e064f3d70fcc914805"), "Name" : "Larry", "Age" : 23 } { "_id" : ObjectId("5c6ab0ef64f3d70fcc914806"), "Name" : "Mike", "Age" : 21 } { "_id" : ObjectId("5c6ab0f864f3d70fcc914807"), "Name" : "Sam", ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
342 Views
To delete the documents from a collection in MongoDB, you need to use remove() method. The syntax is as follows:db.yourCollectionName.remove(yourDeleteValue);Here, let us create a collection with some documents. The query is as follows:>db.deleteDocuments.insert({"UserId":1, "UserName":"Bob", "UserTechnicalSubject":"Introducti on to PL/SQL"}); WriteResult({ "nInserted" : 1 }) >db.deleteDocuments.insert({"UserId":2, "UserName":"Carol", "UserTechnicalSubject":"Introduction to MongoDB"}); WriteResult({ "nInserted" : 1 }) >db.deleteDocuments.insert({"UserId":3, "UserName":"John", "UserTechnicalSubject":"Introduction to MySQL"}); WriteResult({ "nInserted" : 1 }) >db.deleteDocuments.insert({"UserId":4, "UserName":"Maxwell", "UserTechnicalSubject":"Introduction to SQL Server"}); WriteResult({ "nInserted" : 1 })You can display all documents from the collection we created above with the help of find() command. The query is as follows:> db.deleteDocuments.find().pretty();The following ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
233 Views
To insert new documents into a MongoDB collection, you need to use insert() method or save() method.Case 1: Using insert() method.The syntax is as follows:db.yourCollectionName.insert(yourDocument);Case 2: Using save() method.The syntax is as follows:db.yourCollectionName.save(yourDocument);In the above syntax, if your collection name does not exist then MongoDB will create a new collection and insert the document in the collection.The query to insert new documents is as follows for both the cases discussed above.Case 1: Using insert() method. The query is as follows:> db.userInformation.insert({ ... "Name":"John", ... Age:30, ... isStudent:false, ... "Subjects":["Introduction to java", "Introduction to MongoDB"] ... ... Read More
![Amit Diwan](https://www.tutorialspoint.com/assets/profiles/12232/profile/60_57779-1530512459.jpg)
507 Views
BigData and NoSQL are the choice for database solutions nowadays, but that does not mean the crucial features of RDBMS will die. Since 90% of the world data produced in last some years, therefore the need for RDBMS will not end in the near future.The RDBMS market is incrementing with 9% annual growth, as stated by Gartner, a research company. RDBMS is meant to handle organized data. NoSQL and Big Data maybe a preferred choice, but the importance of RDBMS will not end in near future.Managing data on a large scale now needs technologies like Big Data, but RDBMS still ... Read More