- 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 1349 Articles for MongoDB
502 Views
To get substring, use $substr in MongoDB. Let us create a collection with documents −> db.demo176.insertOne({"ProductName":"PRODUCT-1"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3843a09e4f06af551997ef") } > db.demo176.insertOne({"ProductName":"PRODUCT-102"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3843a69e4f06af551997f0") } > db.demo176.insertOne({"ProductName":"PRODUCT-105"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3843aa9e4f06af551997f1") }Display all documents from a collection with the help of find() method −> db.demo176.find();This will produce the following output −{ "_id" : ObjectId("5e3843a09e4f06af551997ef"), "ProductName" : "PRODUCT-1" } { "_id" : ObjectId("5e3843a69e4f06af551997f0"), "ProductName" : "PRODUCT-102" } { "_id" : ObjectId("5e3843aa9e4f06af551997f1"), "ProductName" : "PRODUCT-105" }Following is the query to get substring in MongoDB ... Read More
78 Views
To count only collections that match two fields, use count(). Let us create a collection with documents −> db.demo175.insertOne({"EmployeeName":"Bob", "isMarried":"YES"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3840969e4f06af551997e8") } > db.demo175.insertOne({"EmployeeName":"David", "isMarried":"NO"}); { "acknowledged" : true, "insertedId" : ObjectId("5e38409e9e4f06af551997e9") } > db.demo175.insertOne({"EmployeeName":"Mike", "isMarried":"YES"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3840a79e4f06af551997ea") } > db.demo175.insertOne({"EmployeeName":"Sam", "isMarried":"NO"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3840ae9e4f06af551997eb") }Display all documents from a collection with the help of find() method −> db.demo175.find();This will produce the following output −{ "_id" : ObjectId("5e3840969e4f06af551997e8"), "EmployeeName" : "Bob", "isMarried" : "YES" } { "_id" ... Read More
75 Views
To evaluate one or more values, use $or along with find(). Let us create a collection with documents −> db.demo174.insertOne({"StudentName":"Chris", "CountryName":"US"}); { "acknowledged" : true, "insertedId" : ObjectId("5e383c709e4f06af551997e5") } > db.demo174.insertOne({"StudentName":"David", "CountryName":"UK"}); { "acknowledged" : true, "insertedId" : ObjectId("5e383c779e4f06af551997e6") } > db.demo174.insertOne({"StudentName":"Bob", "CountryName":"AUS"}); { "acknowledged" : true, "insertedId" : ObjectId("5e383c7e9e4f06af551997e7") }Display all documents from a collection with the help of find() method −> db.demo174.find();This will produce the following output −{ "_id" : ObjectId("5e383c709e4f06af551997e5"), "StudentName" : "Chris", "CountryName" : "US" } { "_id" : ObjectId("5e383c779e4f06af551997e6"), "StudentName" : "David", "CountryName" : "UK" } { "_id" : ... Read More
127 Views
To limit the number of values in a field, use MongoDB $slice. Let us create a collection with documents −> db.demo173.insertOne({"ListOfValues":[10, 40, 100, 560, 700, 900]}); { "acknowledged" : true, "insertedId" : ObjectId("5e383a4f9e4f06af551997e4") }Display all documents from a collection with the help of find() method −> db.demo173.find().pretty();This will produce the following output −{ "_id" : ObjectId("5e383a4f9e4f06af551997e4"), "ListOfValues" : [10, 40, 100, 560, 700, 900 ] }Following is the query to limit number of values in a field using MongoDB −> db.demo173.find({}, { "ListOfValues": { "$slice": -2 } } );This will produce the following output −{ "_id" ... Read More
3K+ Views
To find a value in lowercase, use the toLowerCase() method in MongoDB. Use the method in find() to find the value in lowercase.Let us create a collection with documents −> db.demo172.insertOne({"SubjectName":"MySQL"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3838ce9e4f06af551997e1") } > db.demo172.insertOne({"SubjectName":"mongodb"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3838d69e4f06af551997e2") } > db.demo172.insertOne({"SubjectName":"MongoDB"}); { "acknowledged" : true, "insertedId" : ObjectId("5e3838db9e4f06af551997e3") }Display all documents from a collection with the help of find() method −> db.demo172.find();This will produce the following output −{ "_id" : ObjectId("5e3838ce9e4f06af551997e1"), "SubjectName" : "MySQL" } { "_id" : ObjectId("5e3838d69e4f06af551997e2"), "SubjectName" : "mongodb" } ... Read More
208 Views
To re-map the fields of a MongoDB collection, use update() along with $rename. Let us first create a collection with documents −> db.demo171.insertOne( { "Name": "Chris", "Details": { "SubjectName": "MySQL", "CountryName": "US" } } ); { "acknowledged" : true, "insertedId" : ObjectId("5e3837 399e4f06af551997e0") }Display all documents from a collection with the help of find() method −> db.demo171.find();This will produce the following output −{ "_id" : ObjectId("5e3837399e4f06af551997e0"), "Name" : "Chris", "Details" : { "SubjectName" : "MySQL", "CountryName" : "US" } }Following is the query to re-map the fields of a MongoDB collection −> db.demo171.update({}, { $rename : { 'Name' ... Read More
206 Views
In this article, we will learn how to secure Mongo DB on Ubuntu 16.04. In previous versions the Mongo DB is vulnerable to automated exploits because, by default, there is no authentication which was allowed to interact with the database, any user can create, read, modify and destroy the database and the contents, this is because of the Mongo DB daemon which can listen to all interfaces as default settings.Enabling Authentication and Adding Admin UserThis issue has been mitigated in the latest versions of Mongo DB after version 3.x releases, however, the authentication is still disabled as default settings, so ... Read More
452 Views
MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection and document. The official Ubuntu 16.04 MongoDB packages have not yet been published by the MongoDB maintainers. This article explains about “How to install Mongo DB on Ubuntu and start the MongoDB service on boot”Adding the MongoDB RepositoryMongoDB is generally included in a Ubuntu package repositories. However, a legitimate MongoDB repository affords the most upto date version change in an endorsed manner.To carry out this process, we first must import the key for the legitimate MongoDB repository using ... Read More
344 Views
In this article, we will learn how to install and configure the MongoDB on CentOS 7, MongoDB which is an open-source and free database (is a NoSQL database), means it is a document-oriented database, it stores the document which is similar structurally to JSON (in MongoDB it is called as BSON) with high availability, performance and auto scaling. Unlike the RDBMS, it doesn’t need any predefined database schema for adding the data to the database tables. We can alter the schema any point of time without disturbing the existing schema.PrerequisitesCentos 7 installed on the Linux Machine.A user with root user ... Read More
5K+ Views
RDBMSRDBMS stands for Relational Database Management System. It stores data in form of entity as tables. It provides multiple layers on information security. Each table may or may not have a primary key which identifies a record uniquely in a table and a foreign key which indentifies the relationship between two tables. RDBMS uses SQL language to query databases. Examples of popular RDBMS are oracle, sql server, mysql etc.MongoDBMongoDB is a NoSQL database. It is open source. It is a document oriented database and it uses BSON which is binary version of JSON. BSON is a document storage format. MongoDB ... Read More