Find query in mongodb LEARNOVITA

What is MongoDB and its Queries | All you need to know [ OverView ]

Last updated on 04th Nov 2022, Artciles, Blog

About author

Neel Patel (MongoDB Manager )

Neel Patel is a MongoDB Manager for the Respective Industry and has 6+ years of experience working on JavaScript, HTML, CSS, Ajax, jQuery, MongoDB, ReactJS, and VueJS. His articles help to impart knowledge and skills in core fields and give insightful knowledge to students.

(5.0) | 19587 Ratings 2354
    • In this article you will learn:
    • 1.What is MongoDB?
    • 2.MongoDB Features.
    • 3.MongoDB Example.
    • 4.Key Components of MongoDB Architecture.
    • 5.Why Use MongoDB?
    • 6.What is MongoDB Query?
    • 7.Querying MongoDB Collection.
    • 8.Managing Indexes.
    • 9.MongoDB pros and cons.
    • 10.Conclusion.

What is MongoDB?

MongoDB is the document-oriented NoSQL database used for a high volume data storage. Instead of using tables and rows like a traditional relational databases, MongoDB uses the collections and documents. Documents consist of a key-value pairs which are the basic unit of a data in MongoDB. Collections contain sets of a documents and functions that are equivalent to the relational database tables. MongoDB is database that came out in a mid-2000s.

MongoDB Features:

  • Every database consists of collections which in turn contain a documents. Every document may be various with different fields.
  • The size and content of each document may be differ from each other.
  • The document structure is be consistent with how developers build their classes and objects in respective of programming languages.
  • Developers will be often say that their classes are not be rows and columns, but a clear structure with the key-value pairs.

MongoDB Example:

  • A example below shows how a document can be modelled in a MongoDB.
  • The _id field is added by a MongoDB to uniquely identify document in collection.
  • What may note is that a order data (Order ID, Product and Quantity) that would normally be stored in the RDBMS would be stored in a separate table, whereas in a MongoDB it would actually be stored as embedded document in collection. One of the key differences is how data is modelled in a MongoDB.
MongoDB Features

What is MongoDB Query?

MongoDB query is the way to get data from MongoDB database. MongoDB queries provide a simplicity in a process of getting data from a database, it is similar to the SQL query in a SQL database language. While performing query operation, one can also use a criteria or conditions which can be used to retrieve a specific data from database.MongoDB offers a function name in the form of a db.collection_name.find() to perform query operations on a database.

Field selection:

The find() method displays a database collection in the non-structured form ({<'key>:<'value>}), which contains a <'key> “id” auto generated by a MongoDB and data inserted by user or administrator.


  • db.collection_name.find()


  • db.article.find()

This method is used to display all documents present in article collection.

Querying MongoDB Collection:

MongoDB Query Language (MQL) uses syntax similar to the documents, making it intuitive and simple to use for an advanced queries.

Managing Indexes: MongoDB allows to create a indexes, even on nested fields in a subdocuments, to make queries perform well, even when collection is huge.


MongoDB pros and cons:

  • Like the other NoSQL databases, MongoDB does not need a predefined schema. It stores any type of a data. It lets users are create any number of fields in the document, making MongoDB databases simpler to scale than a relational databases.
  • One of benefits of using a documents is that these objects map to native data types in a many programming languages. In addition, having embedded documents reduces need for a database joins, which can reduce the costs.
  • One of main features of a MongoDB is its horizontal scalability, which makes it useful database for the companies running big data applications. In addition, sharding the allows the database to distribute data across the set of machines. Newer versions of a MongoDB also support creation of fields of a data based on sharded key.
  • MongoDB supports the multiple storage engines and offers a pluggable storage engine API that allows third parties to the develop their own storage engines for a MongoDB.
  • The DBMS also has a built-in aggregation capabilities, which allow the users to run MapReduce code directly on a database instead of running MapReduce on a Hadoop. MongoDB also includes its own file system called a GridFS, similar to Hadoop Distributed File System (HDFS). The file system is primarily used for a storing files larger than a BSON’s size limit of 16 MB per document. These similarities allow the MongoDB to be used instead of a Hadoop, although the database software integrates with the Hadoop, Spark, and the other data processing frameworks.


MongoDB is the open source NoSQL database management program. NoSQL is used as alternative to the traditional relational databases. NoSQL databases are quite useful for a working with large sets of a distributed data. MongoDB is the tool that can manage document-oriented information, store or retrieve information.MongoDB supports a various forms of data. It is one of the several non-relational database technologies that originated under a NoSQL banner in mid-2000s – in general, for use in a big data applications and the other processing tasks involving data that do well in rigid relational model. Instead of using a tables and rows as in the relational database, the MongoDB architecture is composed of the collections and documents.An Organisations can use a MongoDB for their ad-hoc queries, indexing, load balancing, aggregation, server-side JavaScript execution, and the other features. The ultimate flexibility of a MongoDB means that it is far from comprehensive list of everything can do with it! For more information.

Are you looking training with Right Jobs?

Contact Us

Popular Courses