Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to access a collection in MongoDB using Python?
MongoDB is a well-known NoSQL database that offers a scalable and flexible approach to store and retrieve data. Using Python with MongoDB enables developers to interact with database collections effortlessly through the PyMongo library. This article explains how to access a MongoDB collection using Python, covering the required steps, syntax, and techniques for connecting to, querying, and manipulating data. Syntax from pymongo import MongoClient # Connect to MongoDB client = MongoClient('mongodb://localhost:27017/') # Access database and collection db = client.database_name collection = db.collection_name # Perform operations collection.insert_one(document) collection.find(query) collection.update_one(filter, update) collection.delete_one(filter) PyMongo ...
Read MoreHow to Install & Setup MEAN Stack on Ubuntu (MongoDB, Express.JS, Angular.JS, Node.JS)
The MEAN stack is a popular web development framework consisting of MongoDB, Express.js, Angular.js, and Node.js. It is an open-source platform that allows developers to create robust web applications quickly and efficiently. In this article, we will guide you through the installation and setup process of the MEAN stack on Ubuntu. Step 1: Install Node.js and NPM Node.js is the runtime environment that allows developers to run JavaScript code outside of the browser. It is the backbone of the MEAN stack. To install Node.js on Ubuntu, follow these steps − Open the terminal on Ubuntu by pressing ...
Read MoreHow to Use Go With MongoDB?
MongoDB is a popular NoSQL database that is widely used in modern web applications. Go, on the other hand, is a fast and efficient programming language that is becoming increasingly popular for building web applications. In this article, we will discuss how to use Go with MongoDB, including how to connect to a MongoDB database and how to perform basic CRUD operations. Installing the MongoDB Driver for Go Before we can start using Go with MongoDB, we need to install the MongoDB driver for Go. The easiest way to do this is by using the following command ? ...
Read MoreHow to restart a NoSQL Database service like MongoDB?
To restart a MongoDB service, use the systemctl command on modern Linux systems. MongoDB runs as a system service called mongod that can be managed through systemd service management tools. Syntax sudo systemctl restart mongod sudo systemctl status mongod sudo systemctl enable mongod Method 1: Using systemctl (Recommended) Check the current status of MongoDB service ? sudo systemctl status mongod mongod.service - MongoDB Database Server Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: https://docs.mongodb.org/manual Restart ...
Read MoreDifference between Hadoop and MongoDB
Hadoop is a Java-based distributed computing framework designed to store and analyze large volumes of data across multiple computer clusters. It processes enormous amounts of structured and unstructured data through its core components: HDFS (Hadoop Distributed File System) for storage and MapReduce for parallel data processing. MongoDB is an open-source NoSQL document database that stores data in BSON format rather than traditional tables, rows, and columns. It's designed to solve performance, availability, and scalability issues of SQL-based databases by offering a flexible, document-oriented approach to data storage. What is Hadoop? Apache Hadoop is a distributed computing platform ...
Read MoreSignUp form using Node and MongoDB
In this article, we will create a simple user sign-up form using Node.js and MongoDB. When users fill out the form and click submit, their details will be saved to the MongoDB database. Installation Before creating the sign-up form, install the following dependencies: Express - Web framework for Node.js to handle HTTP requests npm install express --save Body-parser - Middleware to parse HTTP POST data npm install body-parser --save Mongoose - MongoDB ...
Read MoreConnecting MongoDB with NodeJS
To connect MongoDB with Node.js, use the MongoClient.connect() method from the mongodb package. This asynchronous method establishes a connection between your Node.js application and the MongoDB server. Syntax MongoClient.connect(url, options, callback) Parameters: url − Connection string specifying the MongoDB server location and port options − Optional configuration object (e.g., useUnifiedTopology: true) callback − Function executed after connection attempt with error and client parameters Installation and Setup First, install the MongoDB driver for Node.js ? npm install mongodb --save Start your MongoDB server ? mongod --dbpath=data ...
Read MoreQuerying on an array of objects for specific nested documents with MongoDB?
To query on an array of objects for nested documents in MongoDB, use the find() method with the $elemMatch operator in projection to return only matching array elements. Syntax db.collection.find( {}, { arrayField: { $elemMatch: { condition } } } ); Sample Data db.demo763.insertOne({ _id: 1, ...
Read MoreMongoDB aggregation and projection?
MongoDB aggregation with projection allows you to transform and reshape documents by selecting specific fields, computing new values, and controlling the output structure. The $project stage in the aggregation pipeline passes documents with requested fields to the next stage. Syntax db.collection.aggregate([ { $project: { field1: 1, // Include field field2: 0, // Exclude field ...
Read MoreCheck for duplicates in an array in MongoDB?
To check for duplicates in an array in MongoDB, use the $unwind and $group operators within an aggregation pipeline to identify array elements that appear more than once in the same document. Syntax db.collection.aggregate([ { $project: { arrayField: 1 } }, { $unwind: "$arrayField" }, { $group: { _id: { _id: "$_id", value: "$arrayField" }, count: { $sum: 1 } } }, { $match: { count: { $gt: 1 } } }, { $group: { _id: "$_id._id", ...
Read More