Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • GfG 160: Daily DSA
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Django
  • Views
  • Model
  • Template
  • Forms
  • Jinja
  • Python SQLite
  • Flask
  • Json
  • Postman
  • Interview Ques
  • MongoDB
  • Python MongoDB
  • Python Database
  • ReactJS
  • Vue.js
Open In App
Next Article:
Connect Django Project to MongoDB
Next article icon

Connect Django Project to MongoDB

Last Updated : 15 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Djongo is a SQL to MongoDB query transpiler. Using djongo, we can use MongoDB as a backend database for our Django project. We don't even need to change the Django ORM. The best part is that we can setup Django with MongoDB by adding just one line of code. There is no need to change serializers, views, or any other modules.

Official Docs - https://pypi.org/project/djongo/ 

Working - 
Djongo translates a SQL query string into a MongoDB query document. Therefore, there is no need to change models, serializers, views or any Django features. Django supports all django contrib libraries which make it an easy to use connector. 


Requirements - 

1. Python 3.6 or higher.

2. MongoDB 3.4 or higher. (If you are using nested queries then MongoDB 3.6 or higher is required.)

Features :  

  • Reuse Django Models/ORM - 
    As Django Models are compatible with Djongo, we can use reuse them.
  • Integrity checks 
    Django allows integrity checks like missing values before they are saved to the database.
    For eg- Missing values are never stored if we set null=False, blank=False in EmbeddedField

  • Validators 
    We can apply validation checks like URLValidator, EmailValidator, RegexValidator etc. before each fields are saved to the database.
     


Usage : 

Step 1: Setup Virtual Environment 

virtualenv myenv
myenv\Scripts\activate

Step 2:  Install Django 

pip install django

Step 3: Install Djongo 

pip install djongo

Step 4: Start Django Project 

django-admin startproject geeks_project

Your project structure will look like this :

Step 5:  Make changes to settings.py file 

Now, open settings.py file. Comment out or remove previous SQL Database configuration and add the following code in settings.py file :settings.py

   DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'your-database-name',
}
}



That's it. Now you can Use MongoDB as a backend database for your django project, without changing a single django model!


Next Article
Connect Django Project to MongoDB
author
yuvraj_chandra
Improve
Article Tags :
  • Python
  • MongoDB
  • Python Django
Practice Tags :
  • python

Similar Reads

    MongoDB Tutorial
    In today's data-driven world, the ability to efficiently store, manage and process large volumes of data is crucial. MongoDB, a powerful NoSQL database, has become a popular choice for developers due to its flexibility, scalability, and high performance. Unlike traditional relational databases, Mong
    10 min read

    Introduction

    How do Document Databases Work?
    Document databases are a powerful tool in the world of NoSQL databases, and they play an important role in modern applications, especially where flexibility, scalability, and performance are key requirements. But how exactly do document databases work? In this article, we will go deep into the struc
    6 min read
    How MongoDB works ?
    MongoDB is an open-source document-oriented database. It is used to store a larger amount of data and also allows you to work with that data. MongoDB is not based on the table-like relational database structure but provides an altogether different mechanism for storage and retrieval of data, that's
    3 min read
    MongoDB: An introduction
    MongoDB is a powerful, open-source NoSQL database that offers a document-oriented data model, providing a flexible alternative to traditional relational databases. Unlike SQL databases, MongoDB stores data in BSON format, which is similar to JSON, enabling efficient and scalable data storage and ret
    5 min read
    MongoDB: Getting Started
    Terminologies: A MongoDB Database can be called the container for all the collections. A collection is a bunch of MongoDB documents. It is similar to tables in RDBMS.A document is made of fields. It is similar to a tuple in RDBMS, but it has a dynamic schema here. Documents of the same collection ne
    5 min read
    MongoDB - Working and Features
    MongoDB is a powerful, flexible, and scalable NoSQL database that provides high performance and real-time data processing. Unlike traditional relational databases (RDBMS), MongoDB uses a document-oriented model, allowing developers to store and manage large volumes of unstructured or semi-structured
    8 min read
    Difference between RDBMS and MongoDB
    Both RDBMS and MongoDB are widely used database management systems, but they differ significantly in how they store, manage, and retrieve data. RDBMS (Relational Database Management System) is a traditional approach to database management, while MongoDB is a NoSQL (Non-relational) database known for
    5 min read
    MongoDB vs MySQL
    Both MongoDB and MySQL are popular database management systems (DBMS), but they are built for different purposes and have distinct features. MongoDB is a NoSQL database, designed for handling unstructured data with high scalability, while MySQL is a traditional relational database management system
    6 min read

    Installation

    How to Install and Configure MongoDB in Ubuntu?
    MongoDB is a popular NoSQL database offering flexibility, scalability, and ease of use. Installing and configuring MongoDB in Ubuntu is a straightforward process, but it requires careful attention in detail to ensure a smooth setup. In this article, we'll learn how to install and configure MongoDB i
    5 min read
    How to Install MongoDB on MacOS
    MongoDB is a leading open-source NoSQL database, known for its flexibility, scalability, and high performance. It’s widely used by companies like Adobe, Uber, IBM, and Google for big data applications and real-time analytics. Unlike traditional relational databases, MongoDB stores data in documents
    6 min read
    How to Install MongoDB on Windows?
    Looking to install MongoDB on your Windows machine? This detailed guide will help you install MongoDB on Windows (Windows Server 2022, 2019, and Windows 11) quickly and efficiently. Whether you’re a developer or a beginner, follow this guide for seamless MongoDB installation, including setting up en
    6 min read

    Basics of MongoDB

    MongoDB - Database, Collection, and Document
    MongoDB is a popular NoSQL database that offers a flexible, scalable, and high-performance way to store data. In MongoDB, Databases, Collections, and Documents are the fundamental building blocks for data storage and management. Understanding these components is crucial for efficiently working with
    9 min read
    MongoDB Cursor
    In MongoDB, a cursor is a powerful object that enables us to iterate over the results of a query. When we execute a query using methods like find(), MongoDB returns a cursor object that allows you to efficiently retrieve and process documents from the database one by one. Cursors provide various met
    9 min read
    DataTypes in MongoDB
    MongoDB, a leading NoSQL database, uses BSON (Binary JSON) format to store documents, offering a wide range of data types that allow flexible and efficient data storage. Understanding the different data types in MongoDB is crucial for designing effective schemas, optimizing queries, and ensuring sea
    8 min read
    What is ObjectId in MongoDB
    In MongoDB, each document within a collection is uniquely identified by a field called _id. By default, this field uses the ObjectId format, a 12-byte BSON data type that ensures uniqueness and embeds valuable metadata, such as the creation timestamp. Understanding how ObjectId works is crucial for
    5 min read
    What is a MongoDB Query?
    A MongoDB query is a request to the database to retrieve specific documents or data based on certain conditions or criteria. It is similar to SQL queries in traditional relational databases, but MongoDB queries are written using JavaScript-like syntax. The most common query operation in MongoDB is t
    10 min read
    MongoDB - Create Database using Mongo Shell
    MongoDB is a popular NoSQL database that uses collections and documents, which are highly flexible and scalable. Unlike relational databases (RDBMS), MongoDB does not use tables and rows but stores data in a more dynamic, JSON-like format. In this article, we'll explore how to create a MongoDB datab
    4 min read
    MongoDB | Delete Database using MongoShell
    MongoDB is a NoSQL database system that uses dynamic schemas, making it highly flexible for developers. A MongoDB database acts as a container for collections, where each collection contains documents. In this article, we will explain how to delete databases in MongoDB using the db.dropDatabase() co
    4 min read
    MongoDB CRUD Operations
    CRUD operations Create, Read, Update, and Delete—are essential for interacting with databases. In MongoDB, CRUD operations allow users to perform various actions like inserting new documents, reading data, updating records, and deleting documents from collections. Mastering these operations is funda
    5 min read

    MongoDB Methods

    MongoDB - Insert() Method
    The insert() method in MongoDB is a fundamental operation used to add new documents to a collection. It allows inserting one or multiple documents in a single execution with MongoDB automatically generating a unique _id field if not explicitly provided. In this article, We will learn about the Mongo
    6 min read
    MongoDB insertOne() Method - db.Collection.insertOne()
    MongoDB is a powerful NoSQL database known for its flexibility, scalability, and performance. When working with MongoDB, one of the most common tasks is inserting data into collections. The insertOne() method is an essential tool in this process.In this article, We will learn about the MongoDB inser
    5 min read
    MongoDB insertMany() Method - db.Collection.insertMany()
    MongoDB insertMany() method is a powerful tool for inserting multiple documents into a collection in one operation. This method is highly versatile, allowing for both ordered and unordered inserts, and provides options for customizing the write concern. In this article, We will learn about insertMan
    8 min read
    MongoDB - Bulk.insert() Method
    In MongoDB, the Bulk.insert() method is used to perform insert operations in bulk. Or in other words, the Bulk.insert() method is used to insert multiple documents in one go. To use Bulk.insert() method the collection in which data has to be inserted must already exist. We will discuss the following
    2 min read
    MongoDB - bulkWrite() Method
    The bulkWrite() method in MongoDB is a powerful tool that allows for the execution of multiple write operations with a single command. This method is particularly useful for efficiently performing batches of operations, reducing the number of round trips to the database server and thus improving per
    8 min read
    MongoDB - Update() Method
    MongoDB update operations allow us to modify documents in a collection. These operations can update a single document or multiple documents based on specified criteria. MongoDB offers various update operators to perform specific actions like setting a value, incrementing a value or updating elements
    7 min read
    MongoDB - updateOne() Method
    MongoDB's updateOne() method provides a powerful way to update a single document in a collection based on specified criteria. This method is particularly useful when Accuracy is needed in modifying specific documents without affecting others.In this article, We will learn about MongoDB’s updateOne()
    6 min read
    MongoDB updateMany() Method - db.Collection.updateMany()
    MongoDB updateMany method is a powerful feature used to update multiple documents in a collection that match a specified filter. This method allows developers to efficiently perform bulk update operations, reducing network overhead and improving performanceIn this comprehensive guide, we will explor
    6 min read
    MongoDB - Find() Method
    find() method in MongoDB is a tool for retrieving documents from a collection. It supports various query operators and enabling complex queries. It also allows selecting specific fields to optimize data transfer and benefits from automatic indexing for better performance.In this article, We will lea
    4 min read
    MongoDB - FindAndModify() Method
    The findAndModify() method in MongoDB is a powerful and versatile tool for atomic updates on documents. This method allows us to perform multiple operations such as modifying, removing, or inserting documents while ensuring atomicity, meaning that no other operations can interfere during the modific
    6 min read
    MongoDB - FindOne() Method
    MongoDB is a widely used NoSQL database that allows for flexible and scalable data storage. One of its essential methods findOne() which is used to retrieve a single document from a collection that matches the specified query criteria. This method is particularly useful when we need to fetch one spe
    4 min read
    MongoDB - findOneAndDelete() Method
    MongoDB is a widely used NoSQL database that provides flexibility and scalability for handling large volumes of data. One of the key methods in MongoDB for document deletion is the findOneAndDelete() method. This method allows us to delete a single document from a collection based on specified crite
    6 min read
    MongoDB - db.collection.findOneAndReplace() Method
    The findOneAndReplace() method in MongoDB is a powerful tool for finding and replacing a single document within a collection. This method replaces the first document that matches the specified criteria with a new one. By default, it returns the original document but this can be configured to return
    6 min read
    MongoDB - db.collection.findOneAndUpdate() Method
    The MongoDB findOneAndUpdate() method is used to update the first matched document in a collection based on the selection criteria. It offers various options such as sorting, upserting, and returning the updated document. This method is a part of MongoDB's CRUD operations and provides an easy-to-use
    5 min read
    MongoDB - sort() Method
    The sort() method in MongoDB is an essential tool for developers to order documents returned by queries in a specified manner. By utilizing the sort() method, we can organize our query results in either ascending (1) or descending (-1) order based on one or more fields. MongoDB supports complex sort
    6 min read
    MongoDB - copyTo() Method
    MongoDB copyTo() method is used to duplicate the contents of one collection into another collection within the same database. It's like making a copy of a file on your computer to another location. In this article, We will learn about MongoDB copyTo() Method with the help of examples and so on.Mongo
    3 min read
    MongoDB Count() Method - db.Collection.count()
    MongoDB's count() method is a powerful tool for retrieving the number of documents in a collection that match a specified query. It offers flexibility in filtering and is useful for obtaining quick counts based on various criteria.In this article, We will explain the MongoDB count() method in detail
    5 min read
    MongoDB - countDocuments() Method
    MongoDB provides powerful methods to manage and retrieve data efficiently. One such method is countDocuments(), which allows us to count the number of documents in a collection that match a specified query filter. This method is particularly useful when dealing with large datasets, ensuring accurate
    5 min read
    MongoDB - Drop Collection
    In MongoDB, managing collections is a fundamental aspect of database operations. The MongoDB drop collection command allows us to permanently delete an entire collection along with its documents and indexes. By using the db.collection.drop() method is essential when we need to clear outdated data or
    4 min read
    MongoDB Remove() Method - db.Collection.remove()
    The MongoDB remove() method allows users to remove documents from a collection based on specific criteria. It is a powerful tool in MongoDB that enables both single and bulk document deletion, offering flexibility in managing your database. It supports various options like removing only one document
    5 min read
    MongoDB - db.collection.deleteone()
    The MongoDB deleteOne() method is an essential tool for removing a single document from a collection that matches a specified filter. It is widely used for precise deletion tasks, ensuring that we can manage your MongoDB collections effectively by removing specific documents based on certain criteri
    4 min read
    MongoDB - Distinct() Method
    The distinct() method in MongoDB is a powerful tool used to find unique values for a specified field across a single collection. By retrieving all distinct values associated with a specific key, this method helps eliminate duplicates and enables better analysis and reporting on the dataset.In this a
    3 min read
    MongoDB - limit() Method
    The limit() method in MongoDB is a powerful tool used to control the number of documents returned in a query result. It is particularly beneficial when working with large collections as it allows for the restriction of result set sizes thereby improving performance and reducing client load. In this
    5 min read
    MongoDB - skip() Method
    When working with large datasets in MongoDB, efficient data retrieval becomes crucial. The MongoDB skip() method is an essential tool that allows developers to control which portion of the dataset is returned, improving performance and enabling better data paginationWhat is MongoDB skip()?In MongoDB
    4 min read
    MongoDB | ObjectID() Function
    ObjectID() Function: MongoDB uses ObjectID to create unique identifiers for all the documents in the database. It is different than the traditional autoincrementing integer ID, but it comes with its own set of advantages. An ObjectID is a GUID (Globally Unique Identifier). GUIDs are generated random
    2 min read
    MongoDB - db.collection.CreateIndex() Method
    MongoDB's createIndex() method is used to create indexes on collections which allows for efficient querying and sorting of data. This method supports various types of indexes like text indexes, 2dsphere indexes, 2d indexes and more. It also provides options to customize the index creation process.In
    7 min read
    createIndexes() Method in MongoDB
    MongoDB is a highly scalable NoSQL database that allows flexible data storage. One of the most powerful features for improving query performance is indexing. The createIndexes() method in MongoDB allows developers to create various types of indexes which significantly improve query execution speed a
    5 min read
    MongoDB - getIndexes() Method
    In MongoDB, managing indexes is important for optimizing query performance. The getIndexes() method provides a straightforward way to retrieve information about the indexes on a specific collection. Understanding how to use this method effectively helps developers analyze and manage their indexing s
    4 min read
    MongoDB dropIndex() Method
    Indexes are important in MongoDB for improving query performance, allowing the database to quickly find the documents that match query criteria. The dropIndex() method in MongoDB enables developers to manage their collection's indexes by removing unnecessary or outdated indexes. However, it's import
    5 min read
    MongoDB - dropIndexes() Method
    The MongoDB dropIndexes command is an important tool for managing and optimizing database performance. By removing unnecessary indexes, we can free up system resources and ensure faster query execution. In this article, we’ll explore the dropIndexes() in MongoDB and explain how to use the MongoDB in
    3 min read

    Comparison Operators

    MongoDB - Comparison Query Operators
    MongoDB provides powerful comparison query operators to filter and retrieve documents based on field values. These operators help developers perform precise queries, enabling efficient data retrieval and manipulation. MongoDB uses various comparison query operators to compare the values of the docum
    4 min read
    MongoDB $cmp Operator
    The MongoDB $cmp operator is a powerful tool for comparing two values within documents, commonly used in aggregation pipelines for sorting or conditional operations. It plays a crucial role in sorting, conditional operations, and advanced comparisons inside MongoDB queriesIn this article, We will le
    4 min read
    MongoDB $gt Operator
    The $gt operator in MongoDB is a powerful comparison operator that allows you to query documents where the value of a field is greater than a specified value. It can be used in various methods, such as find, update, and aggregate, making it a flexible tool for data analysis and retrieval.In this gui
    4 min read
    MongoDB - $lt Operator
    MongoDB provides powerful query operators to filter and retrieve data efficiently. One such essential operator is the $lt (less than) operator, which allows users to select documents where a specified field’s value is less than a given value. We can use this operator in methods like, find(), update(
    4 min read
    MongoDB - $eq Operator
    MongoDB provides a variety of comparison query operators to filter and retrieve documents efficiently. One of the most widely used operators is $eq (equal to operator), which allows users to match exact values in a MongoDB collection.In this article, we will explore the MongoDB $eq operator, its syn
    4 min read
    MongoDB - $lte Operator
    MongoDB $lte Operator is one of the comparison operators. $lte operator selects those documents where the field value is less than equal to (<=) the given value. This operator can be used in methods like find(), update(), etc. according to your requirements.. Syntax{field: {$lte: value}}MongoDB $
    2 min read
    MongoDB - $gte Operator
    MongoDB $gte or "greater than equals to" operator is one of the comparison operators. $gte operator selects those documents where the field value is greater than equals to(>=) the given value. This operator can be used in methods (like, find(), update(), etc.) according to your requirements. Synt
    2 min read
    MongoDB - $ne Operator
    MongoDB $ne or "not equals" operator is one of the comparison operators. The $ne operator selects those documents where the field value is not equal to the given value. It also includes those documents that do not contain the specified field. You can use this operator in methods like find(), update(
    2 min read
    MongoDB $in Operator
    MongoDB $in operator provides a powerful way to query documents based on multiple potential values for a specific field within a single query.In this article, We will learn about the MongoDB $in Operator by understanding various examples in detail.MongoDB $in OperatorThe MongoDB $in operator is used
    4 min read
    MongoDB - $nin Operator
    MongoDB $nin or " not in" is one of the comparison query operators. The $nin operator selects those documents where the field value is not equal to any of the given values in the array and the field that does not exist. You can use this operator in methods like find(), update(), etc. according to yo
    2 min read

    Logical Operators

    MongoDB - Logical Query Operators
    Logical query operators in MongoDB are fundamental tools used to combine or modify the results of queries using logical conditions. These operators empower developers to create complex queries by combining multiple conditions and enabling precise filtering of documents based on various criteria.In t
    4 min read
    MongoDB AND operator ( $and )
    MongoDB, a popular NoSQL database, offers several powerful query operators, including the $and operator. This operator enables us to combine multiple conditions in a query to retrieve documents that satisfy all of the specified conditions. The $and operator is a critical tool for building complex, p
    4 min read
    MongoDB OR operator ( $or )
    MongoDB provides various logical query operators, and the $or operator is one of the most powerful among them. It is used to retrieve documents that match at least one of multiple specified conditions, making it ideal for scenarios where multiple filtering criteria need to be considered.In this arti
    6 min read
    MongoDB NOT operator ( $not )
    In MongoDB, the $not operator is a logical query operator that allows us to negate or reverse the condition specified in a query. It plays a crucial role in filtering documents by excluding those that match a given expression. This powerful operator is often used with other comparison operators such
    5 min read
    MongoDB NOR Operator ( $nor )
    MongoDB provides various logical query operators to enable advanced querying capabilities, and one of the most important among them is the $nor operator. This operator performs a logical NOR operation, allowing us to find documents that do not meet the conditions specified in multiple expressions.In
    4 min read

    Arithmetic Operators

    MongoDB $add Operator
    The $add operator in MongoDB is a versatile and essential tool within the aggregation framework. It enables us to perform arithmetic operations like addition on numeric values, as well as concatenate dates and numbers. Whether we are aggregating data or manipulating documents, the $add operator is i
    4 min read
    MongoDB $subtract Operator
    MongoDB’s $subtract operator is an essential tool in the aggregation pipeline, allowing users to perform subtraction operations on numbers, dates, and even date-time calculations. This powerful operator simplifies arithmetic operations within the aggregation pipeline and enhances MongoDB's ability t
    4 min read
    MongoDB $multiply Operator
    In MongoDB, the $multiply operator is a powerful tool used in aggregation pipelines to perform multiplication operations. This operator takes one or more expressions as arguments and multiplies them to produce a result.In this article, we will explain the MongoDB $multiply operator, its syntax, usag
    4 min read
    MongoDB $divide Operator
    In MongoDB, the $divide operator is a powerful tool used to perform division between two numerical values. It allows for precise arithmetic operations directly within the database queries, enhancing the capability to manipulate and analyze data. In this article, We will learn about the MongoDB $divi
    4 min read
    MongoDB $abs operator
    The $abs operator in MongoDB is a fundamental arithmetic expression operator used in aggregation pipeline stages. Its primary function is to calculate the absolute value of a specified number. This operation ensures that only positive values are considered, regardless of the number’s sign, making it
    4 min read
    MongoDB $floor Operator
    The MongoDB $floor operator is a powerful tool used in the aggregation pipeline to round numbers down to the nearest integer that is less than or equal to the original number. Whether we're working with employee performance metrics, financial data, or any numerical dataset, the $floor operator helps
    4 min read
    MongoDB $ceil Operator
    In MongoDB, the $ceil operator is a powerful tool used in aggregation pipelines to round numbers up to the nearest integer greater than or equal to the original number. In this article, We will learn about the MongoDB $ceil Operator in detail. MongoDB $ceil OperatorMongoDB $ceil operator is used in
    3 min read
    MongoDB $mod Operator
    MongoDB provides different types of arithmetic expression operators that are used in the aggregation pipeline stages and $mod operator is one of them. This operator is used to divide one number by another number and return the remainder. Syntax: { $mod: [ , ] }
    1 min read
    MongoDB $sqrt Operator
    MongoDB provides different types of arithmetic expression operators that are used in the aggregation pipeline stages $sqrt operator is one of them. This operator is used to find the square root of a positive number and returns the result as a double. Syntax: { $sqrt: } Here, the numbe
    2 min read
    MongoDB $pow Operator
    MongoDB's $pow operator is a powerful tool within the aggregation framework which is designed to compute exponentiation operations directly on numeric fields. In this article, We will learn about the MongoDB $pow Operator in detail by understanding various examples and so on.MongoDB $pow OperatorThe
    4 min read
    MongoDB $exp Operator
    MongoDB's aggregation framework provides a powerful set of tools for data manipulation and processing. One such tool is the $exp operator which allows users to perform exponential calculations within aggregation pipelines. In this article, We will learn about the MongoDB $exp Operator in detail. Mon
    3 min read
    MongoDB $log Operator
    The MongoDB $log operator is used within the aggregation pipeline to calculate the logarithm of a number with a specified base. This operator helps perform logarithmic calculations on fields whether in simple documents or embedded documents. The syntax is straightforward by requiring a number and a
    3 min read
    MongoDB $log10 Operator
    In MongoDB, the $log10 operator is a powerful tool that allows users to perform mathematical computations directly within the database. This operator returns the base 10 logarithm of a specified number and making it invaluable for data analysis and transformation tasks. In this article, We will lear
    3 min read
    MongoDB $ln Operator
    $in operator in MongoDB is a powerful query tool used to filter documents based on whether a field value matches any value within a specified array. This operator simplifies searching through large datasets by allowing developers to specify multiple values for a single field. In this article, we wil
    5 min read

    Field Update Operators

    MongoDB - Field Update Operators
    MongoDB offers a range of powerful field update operators that enable efficient modification of specific fields within documents. These operators allow developers to update specific fields in documents without rewriting the entire document, thus improving performance and operational efficiency.By gu
    5 min read
    MongoDB - $max Operator
    The $max operator in MongoDB is one of the field update operators used to conditionally update fields within a document. It updates a field only if the specified value is greater than the current value, making it highly efficient for managing thresholds and ensuring data accuracy. This operator is v
    4 min read
    MongoDB - $min Operator
    MongoDB offers a range of powerful update operators, and one of the most useful is the $min operator. This operator updates a field's value to a specified value, but only if that value is smaller than the current field value. If the specified value is greater than or equal to the current value, no u
    5 min read
    MongoDB - $inc Operator
    The MongoDB $inc operator is one of the most commonly used update operators in MongoDB, especially when it comes to modifying numerical values within documents. It is used to increment or decrement the value of a field by a specific amount, making it highly useful for applications like counters, sco
    5 min read
    MongoDB - $mul Operator
    MongoDB $mul operator is a powerful update operator used to multiply the value of a field by a specified number. This operator allows for direct arithmetic operations within the database, making it particularly useful for scenarios that require modifying numeric field values without needing to retri
    5 min read
    MongoDB - Rename Operator ($rename)
    MongoDB $rename operator is a powerful tool for for efficiently renaming fields within documents. This operator ensures data consistency and helps developers maintain a clear and organized schema, especially when working with large collections. Whether you’re dealing with nested documents, arrays, o
    5 min read
    MongoDB - Current Date Operator ($currentDate)
    MongoDB provides different types of field update operators to update the values of the fields of the documents and $currentDate operator is one of them. This operator is used to set the value of a field to the current date (either as a timestamp or as a Date). The default type of $currentDate operat
    2 min read
    MongoDB - $setOnInsert Operator
    The $setOnInsert operator in MongoDB is a powerful tool used in updating operations with the upsert option. It allows us to specify values that should be set only when a new document is inserted. In this article, we will learn about the $setOnInsert Operator in MongoDB in detail and so on. MongoDB $
    4 min read
    MongoDB Bitwise Update Operator
    The MongoDB Bitwise Update Operator allows for efficient manipulation of integer fields within MongoDB documents through bitwise operations. In this article, We will learn about the MongoDB Bitwise Update Operator in detail by understanding various examples in detail.MongoDB Bitwise Update OperatorM
    3 min read

    Array Expression Operators

    MongoDB - $isArray Operator
    In MongoDB, arrays are used to store lists of information such as product categories or tags. The $isArray operator is a tool that helps us to check if a specific field contains an array. This is important for managing data effectively especially when dealing with mixed data types in our collections
    6 min read
    MongoDB $size Operator
    When working with data in MongoDB, arrays are a fundamental data type used to store multiple values in a single field. Whether we're handling lists of tags, categories, or other collections, it's often necessary to determine the size of an array. MongoDB provides the $size operator to help us effici
    5 min read
    MongoDB $arrayElemAt Operator
    MongoDB is a widely used NoSQL database known for its flexible data model. One of the essential features of MongoDB is its support for array data types. The $arrayElemAt operator is a key part of MongoDB's aggregation framework, enabling developers to retrieve specific elements from arrays. Whether
    5 min read
    MongoDB $concatArrays Operator
    MongoDB provides a set of operators for manipulating and transforming data within its powerful aggregation framework. One of the most useful array expression operators is the $concatArrays operator. This operator enables developers to merge multiple arrays into a single, unified array. Whether we're
    4 min read
    MongoDB $reverseArray Operator
    MongoDB is a powerful NoSQL database designed for scalability and flexibility. One of the most useful features MongoDB offers is its ability to handle arrays within documents. The MongoDB $reverseArray operator is part of the aggregation pipeline, allowing developers to easily reverse the order of e
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

'); // $('.spinner-loading-overlay').show(); let script = document.createElement('script'); script.src = 'https://assets.geeksforgeeks.org/v2/editor-prod/static/js/bundle.min.js'; script.defer = true document.head.appendChild(script); script.onload = function() { suggestionModalEditor() //to add editor in suggestion modal if(loginData && loginData.premiumConsent){ personalNoteEditor() //to load editor in personal note } } script.onerror = function() { if($('.editorError').length){ $('.editorError').remove(); } var messageDiv = $('
').text('Editor not loaded due to some issues'); $('#suggestion-section-textarea').append(messageDiv); $('.suggest-bottom-btn').hide(); $('.suggestion-section').hide(); editorLoaded = false; } }); //suggestion modal editor function suggestionModalEditor(){ // editor params const params = { data: undefined, plugins: ["BOLD", "ITALIC", "UNDERLINE", "PREBLOCK"], } // loading editor try { suggestEditorInstance = new GFGEditorWrapper("suggestion-section-textarea", params, { appNode: true }) suggestEditorInstance._createEditor("") $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = true; } catch (error) { $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = false; } } //personal note editor function personalNoteEditor(){ // editor params const params = { data: undefined, plugins: ["UNDO", "REDO", "BOLD", "ITALIC", "NUMBERED_LIST", "BULLET_LIST", "TEXTALIGNMENTDROPDOWN"], placeholderText: "Description to be......", } // loading editor try { let notesEditorInstance = new GFGEditorWrapper("pn-editor", params, { appNode: true }) notesEditorInstance._createEditor(loginData&&loginData.user_personal_note?loginData.user_personal_note:"") $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = true; } catch (error) { $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = false; } } var lockedCasesHtml = `You can suggest the changes for now and it will be under 'My Suggestions' Tab on Write.

You will be notified via email once the article is available for improvement. Thank you for your valuable feedback!`; var badgesRequiredHtml = `It seems that you do not meet the eligibility criteria to create improvements for this article, as only users who have earned specific badges are permitted to do so.

However, you can still create improvements through the Pick for Improvement section.`; jQuery('.improve-header-sec-child').on('click', function(){ jQuery('.improve-modal--overlay').hide(); $('.improve-modal--suggestion').hide(); jQuery('#suggestion-modal-alert').hide(); }); $('.suggest-change_wrapper, .locked-status--impove-modal .improve-bottom-btn').on('click',function(){ // when suggest changes option is clicked $('.ContentEditable__root').text(""); $('.suggest-bottom-btn').html("Suggest changes"); $('.thank-you-message').css("display","none"); $('.improve-modal--improvement').hide(); $('.improve-modal--suggestion').show(); $('#suggestion-section-textarea').show(); jQuery('#suggestion-modal-alert').hide(); if(suggestEditorInstance !== null){ suggestEditorInstance.setEditorValue(""); } $('.suggestion-section').css('display', 'block'); jQuery('.suggest-bottom-btn').css("display","block"); }); $('.create-improvement_wrapper').on('click',function(){ // when create improvement option clicked then improvement reason will be shown if(loginData && loginData.isLoggedIn) { $('body').append('
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.unlocked-status--improve-modal-content').css("display","none"); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { showErrorMessage(e.responseJSON,e.status) }, }); } else { if(loginData && !loginData.isLoggedIn) { $('.improve-modal--overlay').hide(); if ($('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { $('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } } }); $('.left-arrow-icon_wrapper').on('click',function(){ if($('.improve-modal--suggestion').is(":visible")) $('.improve-modal--suggestion').hide(); else{ } $('.improve-modal--improvement').show(); }); const showErrorMessage = (result,statusCode) => { if(!result) return; $('.spinner-loading-overlay:eq(0)').remove(); if(statusCode == 403) { $('.improve-modal--improve-content.error-message').html(result.message); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); return; } } function suggestionCall() { var editorValue = suggestEditorInstance.getValue(); var suggest_val = $(".ContentEditable__root").find("[data-lexical-text='true']").map(function() { return $(this).text().trim(); }).get().join(' '); suggest_val = suggest_val.replace(/\s+/g, ' ').trim(); var array_String= suggest_val.split(" ") //array of words var gCaptchaToken = $("#g-recaptcha-response-suggestion-form").val(); var error_msg = false; if(suggest_val != "" && array_String.length >=4){ if(editorValue.length <= 2000){ var payload = { "gfg_post_id" : `${post_id}`, "suggestion" : `${editorValue}`, } if(!loginData || !loginData.isLoggedIn) // User is not logged in payload["g-recaptcha-token"] = gCaptchaToken jQuery.ajax({ type:'post', url: "https://apiwrite.geeksforgeeks.org/suggestions/auth/create/", xhrFields: { withCredentials: true }, crossDomain: true, contentType:'application/json', data: JSON.stringify(payload), success:function(data) { if(!loginData || !loginData.isLoggedIn) { grecaptcha.reset(); } jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('.suggest-bottom-btn').css("display","none"); $('#suggestion-section-textarea').hide() $('.thank-you-message').css('display', 'flex'); $('.suggestion-section').css('display', 'none'); jQuery('#suggestion-modal-alert').hide(); }, error:function(data) { if(!loginData || !loginData.isLoggedIn) { grecaptcha.reset(); } jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Something went wrong."); jQuery('#suggestion-modal-alert').show(); error_msg = true; } }); } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Minimum 4 Words and Maximum Words limit is 1000."); jQuery('#suggestion-modal-alert').show(); jQuery('.ContentEditable__root').focus(); error_msg = true; } } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Enter atleast four words !"); jQuery('#suggestion-modal-alert').show(); jQuery('.ContentEditable__root').focus(); error_msg = true; } if(error_msg){ setTimeout(() => { jQuery('.ContentEditable__root').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } } document.querySelector('.suggest-bottom-btn').addEventListener('click', function(){ jQuery('body').append('
'); jQuery('.spinner-loading-overlay').show(); if(loginData && loginData.isLoggedIn) { suggestionCall(); return; } // script for grecaptcha loaded in loginmodal.html and call function to set the token setGoogleRecaptcha(); }); $('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked $('body').append('
'); $('.spinner-loading-overlay').show(); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { showErrorMessage(e.responseJSON,e.status); }, }); });
"For an ad-free experience and exclusive features, subscribe to our Premium Plan!"
Continue without supporting
`; $('body').append(adBlockerModal); $('body').addClass('body-for-ad-blocker'); const modal = document.getElementById("adBlockerModal"); modal.style.display = "block"; } function handleAdBlockerClick(type){ if(type == 'disabled'){ window.location.reload(); } else if(type == 'info'){ document.getElementById("ad-blocker-div").style.display = "none"; document.getElementById("ad-blocker-info-div").style.display = "flex"; handleAdBlockerIconClick(0); } } var lastSelected= null; //Mapping of name and video URL with the index. const adBlockerVideoMap = [ ['Ad Block Plus','https://media.geeksforgeeks.org/auth-dashboard-uploads/abp-blocker-min.mp4'], ['Ad Block','https://media.geeksforgeeks.org/auth-dashboard-uploads/Ad-block-min.mp4'], ['uBlock Origin','https://media.geeksforgeeks.org/auth-dashboard-uploads/ub-blocke-min.mp4'], ['uBlock','https://media.geeksforgeeks.org/auth-dashboard-uploads/U-blocker-min.mp4'], ] function handleAdBlockerIconClick(currSelected){ const videocontainer = document.getElementById('ad-blocker-info-div-gif'); const videosource = document.getElementById('ad-blocker-info-div-gif-src'); if(lastSelected != null){ document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.backgroundColor = "white"; document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.borderColor = "#D6D6D6"; } document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.backgroundColor = "#D9D9D9"; document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.borderColor = "#848484"; document.getElementById('ad-blocker-info-div-name-span').innerHTML = adBlockerVideoMap[currSelected][0] videocontainer.pause(); videosource.setAttribute('src', adBlockerVideoMap[currSelected][1]); videocontainer.load(); videocontainer.play(); lastSelected = currSelected; }

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences