MongoDB Overview and Benefits
MongoDB Overview and Benefits
MongoDB - Overview
Like any other database management language, MongoDB is based on a NoSQL
database that is used for storing data in a key-value pair. Its working is based on the
concept of document and collection. It is also an open-source, a document-oriented,
cross-platform database system that is written using C++. In this chapter, you will learn
more about MongoDB and its importance.
Here are some key terminologies that you must know to get into the in-depth of
MongoDB:
What is a Database?
In MongoDB, a database can be defined as a physical container for collections of data.
Here, on the file system, every database has its collection of files residing. Usually, a
MongoDB server contains numerous databases.
What is a Document?
A document can be defined as a collection of key-value pairs that contain dynamic
Overview of MongoDB
schema. Dynamic schema is something that documents of the equal collection do not
require for having the same collection of fields or construction, and a common field is
capable of holdingvarious types of data.
Here is a table showing the relation between the terminologies used in RDBMS and
MongoDB:
RDBMS MongoDB
Database Database
Table Collection
Column Field
● Adobe
● McAfee
● LinkedIn
● FourSquare
● MetLife
● eBay
Overview of MongoDB
● SAP
● A dynamic change in the nature of data - i.e., nowadays data are in structured,
semi-structured, nonstructured as well as polymorphic in type.
● The variety of applications and the type of data feed into them for analysis
has now become more diverse and distributed and is approaching cloud-
oriented.
● Also, modern applications and services are serving tens of thousands of users in
diverse geo-locations, having diverse time zones. So data integrity needs to be
there at all the time.
Data residing in multiple virtual servers and other cloud storage (remote-based) in the
cloud infrastructure can be easily analyzed using the NoSQL database management
techniques and largely when the data set is in a non-structured manner. So, it can be
said that the NoSQL database is intended to overcome the diversity of data, increase
performance, modeling of data, scalability, and distribution, which is usually
encountered in the Relational Databases.
MongoDB - Benefits of Using NoSQL
Whereas unstructured data are haphazard data formats (such as document files,
image files, video files, icons, etc.) where structured data can be pulled out or mine
from unstructured data, but this process usually takes a lot of time. Modern-day data
generated from different applications, services, or sources are a combination of
structured and unstructured both. So, you will need something to store such data to
make your application work properly. NoSQL based languages and scripts can help
in this regard.
1. Document type databases: Here, the key gets paired with a compound data
structure, i.e., document. MongoDB is an example of such type.
2. Key-Value stores: Here, each unstructured data is stored with a key for recognizing
it.
3. Graph stores: In this type of database, data is stored mostly for networked data. It
helps to relate data based on some existing data.
. Wide-column stores: This type of data stores large data sets Cassandra (Used by
Facebook), HBase are examples of such type.
2. Valuable and reliable for big data: Each organization, application, and services are
generating large amounts of data that need to be stored appropriately. It brings
into focus the concept of 'big data,' which focuses on the "industrial revolution of
data". Usually, this is not possible for RDBMS; it is not able to store unstructured
data and different types and vast amounts of data. This is why organizations
turned towards using NoSQL systems such as MongoDB or Hadoop to handle 'big
data' volumes.
case of NoSQL databases, they are intended for less hands-on administration,
having features like data distribution, simplified data models, auto management
and fetching data using simple code, and auto-repairing of data. So,
4. It's cheaper: NoSQL databases are intended for utilizing inexpensive commodity
hardware for constructing clusters of the server, which helps in managing huge
data volumes and transaction of data. On the other hand, traditional RDBMSs
systems want expensive storage and original servers; this means they pose a
higher cost per volumes for storing the data.
5. Agile data models: Traditional database systems usually give immense headaches
for managing the changes in storage and operational architecture, particularly for
the large production ones. In such a system, minor changes need to be monitored
carefully. On the other hand, NoSQL database systems do not contain such
limitations on their data- storage models. They are flexible for any type of
changes in not only the genre of data but also the architecture of data-storage,
allowing comparative agility like the addition of new columns with no significant
alterations or breakdown.
6/4/22, 10:14 AM History of MongoDB
MongoDB - History
Since you are now familiar with the various features of MongoDB, and its
characteristics and how it is related to NoSQL, it is time to know the history of
MongoDB. In this chapter, you willbriefly learn the history of MongoDB.
The development of MongoDB was started in early 2007 when the company was
developing a Microsoft Azure-like platform as a service. This was a New York based
company name 10gen which is now changed its name to MongoDB Inc. The initial
development was focused on building a PaaS (Platform as a Service), but later in 2009,
MongoDB came to the market as an open-source database server and was maintained
by this organization itself.
In the year March 2010, it launched its first ready product which was version 1.4. The
latest, as well as the stable version of MongoDB, is version 2.4.9 that was released on
Jan 10, 2014.
MongoDB - Environment Setup
This will open a download page where you can select the version, platform, and
package options.
5.8M
Elon Musk Faces SEC Investigation and Lawsuit by Twitter Investors for Delayed
Disclosure
Here, we will download the latest version of MongoDB, Windows platform, and msi file
as a package, as shown below.
Download MongoDB
Click on the Download button to download the installer file.
MongoDB - Environment Setup
Once fully downloaded, click on the msi file to start the installation wizard, as shown
below.
Check the "I accept the terms in the License Agreement" checkbox and click Next.
In the custom setup page, expand the MongoDB node to see what all features will be
installed. It will install Server, Client, Router, and Miscellaneous Tools for the MongoDB
database. It also displays the location where the MongoDB is going to be installed. You
may change it or keep the default location and click Next.
Click Next to configure the MongoDB service, as shown below.
MongoDB server will be installed as a service on your local Windows machine. As you
can see above, you have an option to run a service as Network Service user or as a
local or domain user. We will select "Run service as Network Service User" radio
button.
You may change the default service name but it is recommended to keep the default
"MongoDB" name to identify it easily.
MongoDB database stores the data as BSON files on your local machine. You can
change the default location where the data files and log files are going to be stored.
Here, we will keep the default paths and click the Next button.
On the next page, select "Install MongoDB Compass" checkbox and click Next.
MongoDB - Environment Setup
MongoDB Compass is a GUI tool for MongoDB database where you can visually explore
data, run queries, and optimize performance.
MongoDB Installation
It will take a few minutes to install. Once installed succefully, click on the Finish button
to close the wizard.
MongoDB - Environment Setup
MongoDB Installation
It will also open MongoDB Compass, as shown below.
MongoDB Compass
MongoDB - Environment Setup
MongoDB Server
We installed MongoDB as a Network service. To see this, open Services by searching
"service" in the windows search box and click on the Services app, as shown below.
MongoDB Service
On the Services window, navigate to MongoDB Server, as shown below. You will find
that it is already up and running.
client to connect with this MongoDB server and execute the commands.
MongoDB Client
MongoDB clients can be your application, MongoDB Shell, MongoDB Compass, or
anything which wants to connect and store data to the MongoDB server.
Here, we already installed two clients, MongoDB Shell and MongoDB Compass.
MongoDB Shell
You can execute the commands here. For example, write "show dbs" and press Enter
MongoDB - Environment Setup
Thus, you can install the MongoDB server, clients (MongoDB Shell and Compass), and
other features.
MongoDB Shell
MongoDB Shell is the quickest way to connect, configure, query, and work with your
MongoDB database. It acts as a command-line client of the MongoDB server.
The MongoDB Shell is a standalone, open-source product and developed separately
from the MongoDB Server under the Apache 2 license. It is a fully functional JavaScript
and [Link] 14.x REPL for interacting with MongoDB servers.
MongoDB Shell is already installed with MongoDB. You can find it in the installation
directory where you installed MongoDB. By default, it is "C:\Program
Files\MongoDB\Server". Open the installation folder and appropriate version folder and
go to the "bin" folder. Here, "[Link]" is MongoDB shell. Click on it to open the
MongoDB shell, as shown below.
MongoDB - Environment Setup
MongoDB Shell
New MongoDB Shell - mongosh
In the installation folder, if you find [Link] instead of [Link] then you
already have a new MongoDB shell. If you don't find it, then you need to install it
separately.
The new MongoDB Shell mongosh has some more features than old shell mongo such
as intelligent autocomplete and syntax highlighting, easy to understand error
messages, formatting feature to present the output in a readable format, etc.
However, all the commands will be executed in mongosh as well as mongo shell.
Install mongosh
To install the new MongoDB shell (mongosh), visit [Link] and click on
Product menu -> Tools -> Database Shell, as shown below.
MongoDB - Environment Setup
On the MongoDB Shell page, click on the Download button to download the shell.
Once installation completes, click the Finish button to close the wizard.
You can execute MongoB commands for CRUD operations on MongoDB shell (mongo or
mongosh). For example, execute the "shows dbs" command to see all the databases
on the connected MongoDB server.
> show dbs
MongoDB - Environment Setup
admin 41 kB
config 111 kB
local 41 kB
MongoDB Compass
MongoDB Compass is a GUI based tools (unline MongoDB Shell) to interact with local
or remote MongoDB server and databases. Use Compass to visually explore your data,
run ad hoc queries, perform CRUD operations, and view and optimize your query
performance. It can be installed on Linux, Mac, or Windows.
If you have not installed MongoDB Compass with the MongoDB, then download the
free community version of Compass for your platform from here.
Now, do a window search on "mongodb compass" and open it, as shown below.
MongoDB Compass
MongoDB - Environment Setup
On the main page, click on the New Connection tab on the left pane to open New
Connection page shown above. You can paste a connection string or click on Fill in
connection fields individually link. This will open the following window where you can
enter the host name, port, username, password, etc.
MongoDB Compass
This already has default parameters, just click OK to connect with your local server, as
shown below.
MongoDB Compass
As you can see above, it will display all the databases on the connected MongoDB
server. On the left pane, it displays information about the connected server.
Now, you can create, modify, delete databases, collections, documents using MongoDB
MongoDB - Environment Setup
Compass. Click on the CREATE DATABASE button to create a new database. This will
open Create Database popup, as shown below.
Thus, you can use MongoDB Compass UI to manage your MongoDB databases.
Database Create and Drop in MongoDB
In this MongoDB tool, you need not have to produce, or it is optional to create a
database manually. This is because MongoDB has the feature of automatically creating
it for the first time for you, once you save your value in that collection. So, explicitly,
you do not need to mention or put a command to create a database; instead it will be
created automatically oncethe collection is filled with values.
Syntax:
use my_project_db
Example:
6/4/22, 10:17 AM Create Collection in MongoDB
Here 'use' is the command for creating a new database in MongoDB and
'my_project_db' is the name of the database. This will prompt you with a message
that it has switched to a new DB (database) name 'my_project_db'.
show dbs
In order to make a list show your database name, you have to make use of the command:
Example:
[Link]({"name":"Avengers: Endgame"})
Now, when you again use the show dbs command, it will now show your created
database name in the list.
It is to be noted that, for checking your currently selected database, you can
use the command:
db
6/4/22, 10:17 AM Create Collection in MongoDB
If you are familiar with SQL, then you must have heard about the drop command. The
concept of drop in SQL is used to delete the entire database or just the table, i.e., it
destroys the objects like an existing database. In MongoDB, the dropDatabase
command is implemented for a similar purpose. This also helps in deleting the
connected data files of that database. For operating this command, you have to reside on
the current database.
Example:
[Link]()
{ "dropped": "my_project_db", "ok": 1}
This will drop the existing database in which you are residing and will show the above
message.
6/4/22, 10:17 AM Create Collection in MongoDB
In the case of MongoDB, data representation is done in JSON document format, but
here the JSON is binary-encoded, which is termed as BSON. BSON is the extended
version of the JSON model, which is providing additional data types, makes
performance to be competent to encode and decode in diverse languages and ordered
fields.
Integer
Integer is a data type that is used for storing a numerical value, i.e., integers as you
can save in other programming languages. 32 bit or 64-bit integers are supported,
which depends on the server.
Example:
[Link]({"Integer example": 62})
6/4/22, 10:17 AM Create Collection in MongoDB
Output:
Boolean
Boolean is implemented for storing a Boolean (i.e., true or false) values.
Example:
Output::
Double
Double is implemented for storing floating-point data in MongoDB.
Example:
Output:
6/4/22, 10:17 AM Create Collection in MongoDB
Min/Max keys
Min / Max keys are implemented for comparing a value adjacent to the lowest as
well ashighest BSON elements.
String
String is one of the most frequently implemented data type for storing the data.
Example:
Output:
Arrays
Arrays are implemented for storing arrays or list type or several values under a single key.
Example:
Output:
6/4/22, 10:17 AM Create Collection in MongoDB
Object
Object is implemented for embedded documents.
Example:
Output:
Symbol
Symbol is implemented to a string and is usually kept reticent for languages having
specific symbol type.
Null
Null is implemented for storing a Null value.
Example:
6/4/22, 10:17 AM Create Collection in MongoDB
Output:
Date
Date is implemented for storing the current date and time as UNIX-time format.
Example:
var month=[Link]()
[Link]({"Date":date, "Date2":date2,"Month":month})
Output:
Timestamp
Timestamp stores 64-bit value, in which the first 32 bits are time_t value (seconds epoch)
and the other 32 bits are ordinal to operate within a given second.
Binary data
Binary data is implemented for storing binary data.
6/4/22, 10:17 AM Create Collection in MongoDB
Object ID
Object ID is implemented for storing the ID of the document.
Regular expression
Regular expression is implemented for storing regular expression.
Code
Code is implemented for storing JavaScript code for your MongoDB
document. In the next chapters, all data types and uses have been
Syntax:
[Link](collection_name, options)
Here, [Link]() is the method used; "name" is a data type - string which
is specifying the name of the collection to be formed. "options" is an added document
type which helps in specifying the size of memory along with indexing the collection in
the database. This parameter is an optional one.
The following example shows the syntax of the createCollection() method with its options:
Example:
validationAction:
<string>,
indexOptionDefaults: <document>,
viewOn: <string>,
pipeline: <pipeline>,
collation: <document>,
writeConcern: <document>} )
Here is the detailing of some important fields that can be used as options in the
createcreateCollection() method:
Field for
Type Description
option
size Number This option is used to specify the ceiling size in bytes for
capped collection. When the capped value is set as true,
you are required to specify this field also.
Example:
[Link]("MyCollection")
Output:
6/4/22, 10:17 AM Create Collection in MongoDB
Example:
[Link]({"name":"Avengers: Endgame"})
The above operation will automatically create a collection if the collection with this name
does not currently exist. Also, if you want to check an inserted document, you can use
the find() method. Its syntax is:
db.collection_name.find()
Output
:
6/4/22, 10:20 AM Drop Collection in MongoDB
Syntax:
db.collection_name.drop()
Continuing from the example in the previous lesson where you have created a
collection inside the my_project_db database. Now use this database to remove or
drop the moviecollection and see the changes:
Example:
use
my_project_db
[Link]
() show
collections
Output:
Query Operations in MongoDB
The insert operation is one of the crucial operations in the database system. MongoDB
supports the below mentioned three methods to insert document data in your database:
1. insert()
2. insertOne()
3. insertMany()
Syntax:
db.collection_Name.insert(JSON document)
In the above syntax, the document will consist of { name: "data_value" }. As it is a JSON
document, these documents will consist of the data as name-value pairs, surrounded by
curlybraces, i.e. {}.
Syntax:
[Link]({"name":"Avengers: Endgame"})
[Link]()
2/3
Query Operations in MongoDB
Output:
method. Let us take an example where you can insert multiple documents at a time:
Example:
[Link](
[
{ name: "Avengers: Infinity War" },
{ name: "Avengers: Endgame" }
]
)
It is to be noted that the documents are supplied in the form of an array. Document
values are packed or enclosed in square brackets [] and separated by commas.
Executing the above statements will pop up with messages something like this:
Output:
3/3
Query Operations in MongoDB
Embedded Documents
MongoDB also allow users to create document containing other documents, arrays of
values,as well as arrays of documents.
Example:
[Link]({
writername: "Stan Lee",
comics: [
{ comics: "DC Comics", year: 2004, name: "Superman" },
{ project: "DC Comics", year: 2001, level: "Batman" },
{ project: "Marvel Comics", year: 1968, level: "Captain America" }
]
})
Output:
4/3
Query Operations in MongoDB
Another way to insert documents is by using the insertOne() method for a single
document ina collection:
Example:
In this case, you have a particular non-existent collection of data. In the case of the
insert() method, a precise collection will get produced in case it does not exist
previously.
Here you will observe that the output appeared to be different in format than that of
insert()method:
Output:
insertMany() Method
As the name is explaining its working, is used for inserting multiple documents:
Example:
[Link](
[
{ _id: 20, devname: "John Wick", tools: "Visual Studio", born: 1948 },
{ _id: 21, devname: "Ganesh Roy", tools: "Net Beans", born: 1945 },
{ _id: 22, devname: "Deeksha Raul", tools: "Unity 3D", born: 1954 }
]
)
Output:
5/3
Query Operations in MongoDB
Let us assume a situation where your database has an employee table, and you wish to
track the sales performance ID, so you have to write a query to ask your database to
fetch for you the list of all the sales performance with the highest sales data in the top.
This is where the queries of a database language become useful.
db.collection_name.find()
Example:
[Link]()
Various other options can be used to make the query specific. It will be
6/3
Query Operations in MongoDB
discussedbelow.
2. The pretty() method: This method is used for giving a proper format to the
outputextracted by the query.
The basic syntax for using this method is:
Syntax:
db.collection_name.find().pretty()
Example:
[Link]().pretty()
Example:
Output:
7/3
Query Operations in MongoDB
Example:
Example:
Output:
8/3
Query Operations in MongoDB
Let us assume a situation where your database has an employee table, and you wish to
track the sales performance ID, so you have to write a query to ask your database to
fetch for you the list of all the sales performance with the highest sales data in the top.
This is where the queries of a database language become useful.
db.collection_name.find()
Example:
[Link]()
Various other options can be used to make the query specific. It will be
Query Operations in MongoDB
discussedbelow.
2. The pretty() method: This method is used for giving a proper format to the
outputextracted by the query.
The basic syntax for using this method is:
Syntax:
db.collection_name.find().pretty()
Example:
[Link]().pretty()
Example:
Output:
Example:
Example:
Output:
$in operator
The $in operator is another special operator used in queries for providing a list of values
in the query. When your document holds any of those provided values, it gets returned.
Here is an example:
Example:
Output:
6/4/22, 10:22 AM Projection Queries in MongoDB
Projection Queries
Protection queries are a particular type of MongoDB queries where you can specify
fields you want to get in the output. MongoDB allows you to perform a query for a
collection by using the [Link]() method, where you have to mention the
field that needs to be explicitly returned. This can be done by explicitly incorporating the
field names in your query, and adding a 1 or 0 with them for specifying whether this
needs to be returned or not. Such kinds of parameters are called projection parameter.
When a projection parameter is associated with a value 1, it will show the value
according to the query and hide when the projection parameter has a value 0.
Without Projection
Here is an example where the projection parameter is not used:
Example:
[Link]()
Output:
6/4/22, 10:22 AM Projection Queries in MongoDB
With Projection
Another example where the projection parameter is used:
Example:
Output:
In the example above, the _id field is excluded, which automatically gets added, and the
title
and author fields are displayed.
6/4/22, 10:22 AM Limiting Query Result in MongoDB
Without Limit
Here is an example where the Limit method is not used:
Example:
[Link]().pretty()
Output:
6/4/22, 10:22 AM Limiting Query Result in MongoDB
In the above example, you can see that three results are showing as output.
With Limit
Another example where the Limit method is used:
Example:
[Link]().pretty().limit(2)
Output:
In the above example where the limit() method is used, you can see that only two
results are seen in the form of output because we have passed the parameter in the
limit() method to display only two records.
Skipping Documents
It is also possible to skip some documents from a MongoDB database. You can perform
such operations using the skip() method of MongoDB. In other words, it can be said
that users have the power to manage or regulate where MongoDB begins returning the
query results.
Example:
[Link]().pretty().skip(1)
6/4/22, 10:22 AM Limiting Query Result in MongoDB
Output:
Update Documents in MongoDB
You have to put some specific condition in the form of the parameter to update the
documentin MongoDB. Here is a stepwise representation of how this can be performed:
Syntax:
[Link](
<query>,
<update>,
{
upsert: <boolean>,
multi: <boolean>,
writeConcern: <document>,
collation: <document>,
arrayFilters: [ <filterdocument1>, ... ]
}
)
Update Documents in MongoDB
Example:
Output:
So, now let us update the list of instrument played by this person, by making use of the
$set
operator for updating a single field.
Example:
[Link](
{_id: 4},
{
$set: { instrument: ["Vocals", "Violin", "Octapad"] }
}
)
Output:
Update Documents in MongoDB
In other words, it can be said that the save() is a blend of both update() as well as
insert(). As the save() method is used, the document that exists will get updated.
Otherwise, when it does not exist, it will create one. When an _id field is not specified,
MongoDB automatically creates a document with this _id containing an ObjectId value
(as conducted by the insert()method).
Example:
[Link]({
"_id": 4,
"name": "Steven Morse",
"instrument": "Violin",
"born": 1954
})
Output:
Delete Documents in MongoDB
MongoDB allows you to delete a document or documents collectively using its one
of the three methods. Three methods provided by MongoDB for deleting documents
are:
1. [Link]()
2. [Link]()
3. [Link]()
[Link]() Method
This method is used to delete only a single document, even when more than one
document matches with the criteria. Here is an example of using this
[Link]() method for deleting the single document. To perform this
process here, we have created a databaseand saved all the data separately.
Example:
[Link]
sert([
{ name: "James Gosling" },
{ name: "Dennis Ritchie" },
{ name: "Bjarne Stroustrup" }
]
)
Delete Documents in MongoDB
Once the insertion process is done, you can run the query (mentioned below) to
return multiple results:
Example:
[Link]()
Output:
Once you execute the above line, you will find that some documents match your query
criteria and will get displayed as output. Now, you can make use of the following criteria
to delete thedocuments.
Example:
Executing this statement, you will notice that, although two documents match the
criteria,only one document gets deleted.
Example:
Delete Documents in MongoDB
[Link]( {} )
Output:
But, when the filtering is done for removing elements, the [Link]()
method willdocument which matches the specified criteria.
Here, we delete all documents where the artist name is "James Gosling".
Example:
Output:
[Link]() Method
MongoDB allows you to delete multiple documents using the
[Link]() method. This method deletes all your documents
whichever match its criteria mentioned in the parameter. To check its implementation
of [Link]() method, you can use the method the same way as done
previously:
Example:
Output:
In this way, continuing from the previous example implementation, now all the records
were also deleted, and the deleteMany() method was used this time. Now, if you try to
find the documents using find() method, it won't show any result of your query or search.
Concept of Aggregation in MongoDB
MongoDB - Concept of
Aggregation
When MongoDB users want to gather metrics from a MongoDB database, aggregation
of MongoDB is the best tool for this. Bundling the data from numerous record sources
which are then operated in various ways on a pool of data for returning a combined
result is what MongoDB allows its users. In this chapter, you will learn about the
concept of aggregation thats supported by MongoDB.
What Is Aggregation?
In MongoDB, aggregation can be defined as the operation that is used for processing
various types of data in the collection, which returns a calculated result. The concept of
aggregation mainly clusters out your data from multiple different documents which are
then used and operates in lots of ways (on these clustered data) to return a combined
result which can bring new information to the existing database. You can relate
aggregation to that of the count(*) along with the 'group by' used in SQL since both are
equivalent in terms of the working.
For performing such an aggregate function, the aggregate() method is used. The
Concept of Aggregation in MongoDB
Syntax:
db.collection_name.aggregate(aggregate_operation)
Example:
[Link]()
Output:
Example:
Output:
The above-executed aggregate() method will give the result shown. It says that
there are three records which do not have any specific type and are available
within the collection "programmers" for aggregating. Hence, the above aggregation
method has clustered thecollection's data in its best possible way.
Another example where we have a collection named writers, which has the following data:
Example:
Sorting in MongoDB
Example:
Output:
Expressi Description
on
$min finds and returns the minimum of all values from within a
collection.
$max finds and returns the maximum of all values from within a
collection.
MongoDB - Sorting
Sorting is one of the necessary database operations. It helps to simplify readability
and sort the data as per the requirement. In this chapter, you will learn about sorting
concept and how it can be implemented in the MongoDB database.
Syntax:
The basic syntax for the sort() method is:
Example:
Consider a collection that is having the following data:
Suppose I want to get data only from the topic field from all the documents in
ascending order, then it will be executed like this:
Example:
Output:
It is to be noted that in case you do not state or explicitly define the sorting preference (1
or
-1), then, the sort() method will exhibit your documents in ascending order by
default. To display the topic field of all the techSubjects in descending order:
Example:
Keep in mind that you can also sort the documents based on the field you do
not want to display.
Example:
Sorting in MongoDB
Syntax:
db.collection_name.find(
<MongoDB query statement>,
{ value: { $meta: <metadataKeyword> } }
)
Output
:
[Link]({},
{ count: { $meta: "textCount" } }
).sort( { count: { $meta: "textCount" } } )