Found 1353 Articles for MongoDB

How to restart a NoSQL Database service like MongoDB?

Satish Kumar
Updated on 01-Dec-2022 08:57:14
If we're going to use a NoSQL DB for our app, then we want something fast and easy to use. We learn that "NoSQL" doesn't necessarily imply "no maintenance". We think about using managed hosting services like MongoDB's Atlas or Amazon's DynamoDB, but we choose to host it ourselves, whether on our premises or in our own cloud instance. We evaluate several NoSQL options including Redis and Cassandra and pick MongoDB. We may be able to get it installed by installing it from our Linux distribution, using Mongo’s repositories, or using a snap. But if something goes wrong, we might ... Read More

Difference between Hadoop and MongoDB

Pradeep Kumar
Updated on 25-Jul-2022 09:43:53
Hadoop was built to store and analyze large volumes of data across several computer clusters. It's a group of software programs that construct a data processing framework. This Java-based framework can process enormous amounts of data quickly and cheaply.Hadoop's core elements include HDFS, MapReduce, and the Hadoop ecosystem. The Hadoop ecosystem is made up of many modules that help with system coding, cluster management, data storage, and analytical operations. Hadoop MapReduce helps analyze enormous amounts of organized and unstructured data. Hadoop's parallel processing uses MapReduce, while Hadoop is an Apache Software Foundation trademark.Millions of people use MongoDB, an open-source NoSQL ... Read More

SignUp form using Node and MongoDB

Mayank Agarwal
Updated on 29-Apr-2021 09:30:47
In this article, we will create a simple user sign-up form having some parameters. On clicking SAVE, all the user details will be saved in the MongoDB database.InstallationBefore proceeding to create the sign-up form, the following dependencies must be succesfully installed on your system.Check and install express by using the following command. Express is used to set middlewares to respond to HTTP requestsnpm install express --saveSetup the "body-parser" node module for reading the HTTP POST data.npm install body-parser --saveSetup "mongoose", as it sits on top of Node's MongoDB driver.npm install mongoose --saveExample 1Create the following files and copy paste the ... Read More

Connecting MongoDB with NodeJS

Mayank Agarwal
Updated on 27-Apr-2021 09:11:43
Introduction to mongodb.connectThis method is used to connect the Mongo DB server with our Node application. This is an asynchronous method from MongoDB module.Syntaxmongodb.connect(path[, callback])Parameters•path – The server path where the MongoDB server is actually running along with its port.•callback – This function will give a callback if any error occurs.Installing Mongo-DBBefore proceeding to try connect your application with Nodejs, we need to setup our MongoDB server first.Use the following query to install mongoDB from npm.npm install mongodb –saveRun the following command to set up your mongoDB on the specific localhost server. This will help in creating connection with the ... Read More

MongoDB and Python

Pradeep Elance
Updated on 10-Jul-2020 11:17:08
MongoDB is a widely used document database which is also a form of NoSQL DB. Python can interact with MongoDB through some python modules and create and manipulate data inside Mongo DB. In this article we will learn to do that. But MongoDB should already be available in your system before python can connect to it and run. To setup MongoDB in your system please visit our  MongoDB tutorial here..Install pymongoTo interact with MongoDB we need the module names pymongo. Install it in your python environment using the below command.pip install pymogoCheck the Existing DBsWe now use this python module ... Read More

MongoDB Aggregate group multiple result?

AmitDiwan
Updated on 01-Jul-2020 07:03:26
To aggregate multiple result, use $group in MongoDB. Let us create a collection with documents −> db.demo765.insertOne( ... ...    { ...       Name:"John", ...       "Category":"ComputerScience", ...       "SubjectName":"MongoDB", ...       "Marks":75 ...    } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5eb054525637cd592b2a4b01") } > > db.demo765.insertOne( ...    { ...       Name:"John", ...       "Category":"ComputerScience", ...       "SubjectName":"MySQL", ...       "Marks":85 ...    } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5eb054525637cd592b2a4b02") } > db.demo765.insertOne( ... ... Read More

MongoDB checking for not null?

AmitDiwan
Updated on 01-Jul-2020 07:00:01
Use $ne to check for not null. Let us create a collection with documents −> db.demo764.insertOne({"LoginUserName":"Chris", "LoginPassword":"Chris_12"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5eb04ee55637cd592b2a4afc") } > db.demo764.insertOne({"LoginUserName":"Chris", "LoginPassword":null}); {    "acknowledged" : true,    "insertedId" : ObjectId("5eb04eee5637cd592b2a4afd") } > db.demo764.insertOne({"LoginUserName":"Chris", "LoginPassword":""}); {    "acknowledged" : true,    "insertedId" : ObjectId("5eb04ef35637cd592b2a4afe") }Display all documents from a collection with the help of find() method −> db.demo764.find();This will produce the following output −{ "_id" : ObjectId("5eb04ee55637cd592b2a4afc"), "LoginUserName" : "Chris", "LoginPassword" : "Chris_12" } { "_id" : ObjectId("5eb04eee5637cd592b2a4afd"), "LoginUserName" : "Chris", "LoginPassword" : null } { "_id" : ObjectId("5eb04ef35637cd592b2a4afe"), "LoginUserName" : "Chris", ... Read More

Querying on an array of objects for specific nested documents with MongoDB?

AmitDiwan
Updated on 01-Jul-2020 06:58:37
To query on an array of objects for nested documents, use find(). Let us create a collection with documents −> db.demo763.insertOne( ...    { ...       _id:1, ...       CountryName:"US", ...       "studentInformation": [ ...          { ...             StudentName:"Chris", ...          }, ...          { ...             StudentName:"David", ...             StudentAge:22 ...          } ...       ] ...    } ... ); { "acknowledged" : true, "insertedId" : 1 }Display all documents from a collection with the help of find() method −> db.demo763.find();This will produce the following output −{ "_id" : 1, "CountryName" : "US", "studentInformation" : [ { "StudentName" : "Chris" }, { "StudentName" : "David", "StudentAge" : 22 } ] }Following is how to query an array of objects to fetch specific nested documents −> db.demo763.find({}, ... { ...    studentInformation: { ...       $elemMatch: { ...          StudentAge: { ...             $exists: true ...          } ...       } ...    } ... })This will produce the following output −{ "_id" : 1, "studentInformation" : [ { "StudentName" : "David", "StudentAge" : 22 } ] }

MongoDB aggregation and projection?

AmitDiwan
Updated on 01-Jul-2020 06:57:21
For this, use $project along with aggregate(). The $project in aggregation passes along the documents with the requested fields to the next stage in the pipeline.Let us create a collection with documents −> db.demo762.insertOne({ ...    "_id" : { ...       "userId":101, ...       "userName":"Chris" ...    }, ..   . "countryName" : "US", ... ...    "details" : [ ...       { ...          "Name" : "Robert", ...          "DueDate" : "2020-04-10" ... ...       }, ... ...       { ...     ... Read More

Query an array in MongoDB to fetch a specific value

AmitDiwan
Updated on 01-Jul-2020 06:54:10
To fetch a specific value from an array, use aggregate() along with $project. Let us create a collection with documents −> db.demo761.insertOne( ...    { ...       "details": [ ...          { ...             "student": { ...                "FullName": "Chris Brown" ...             } ...          } ...       ] ...    } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5eb034d15637cd592b2a4af1") } > db.demo761.insertOne( ...    { ...       ... Read More
1 2 3 4 5 ... 136 Next
Advertisements