Mongodb find by id, findone, find in array, find like, find limit, find count, Mongodb projection

Introduction

In the real-world application, we use a database to store the data be it a relational database or any NoSQL database. Apart from storing the data, we need to retrieve the data well. Querying the data is very important in terms of performance and memory uses. It is a good idea to fetch the relevant data only, as loading the unnecessary data will cause a performance hit as well as additional memory uses.

Mongodb

There can multiple requirements to fetch the data, in this post I will explain the following ways to fetch the data in MongoDB.

  • Mongodb find by id
  • Mongodb findone
  • Mongodb find
  • Mongodb find with limit
  • Mongodb Sort
  • Mongodb Projection
  • Mongodb find count
  • Mongodb findone latest
  • Mongodb find like
  • Mongodb find in array
  • Mongodb cursor to toArray

I have created a database company and created a collection of employees inside it and I will use the same database and collection in the entire post. You can download the sample employees’ data file from here. You can import this sample file in MongoDB using the below commands from Mongo Shell. If you are not familiar with Mongo Shell, you can check my previous post on Setting up MongoDB and an introduction to the shell.

mongoimport employees.json -d company -c employees --jsonArray

-d is the name of the database

-c is the name of the collection

If the JSON file is an array pass -–jsonArray

If you want to drop the database if it exists pass -–drop in the above command

Mongodb find

Mongodb find by id

In Mongodb, every document inside a collection will have a primary key that is denoted by _id. It is an ObjectID, one of the BSON data types of MongoDB, using this record inside a collection can be differentiated. Also, Mongodb automatically indexed this. 

As it holds a unique value for each document, we can fetch that particular document using this. Let’s check it with an example. 

Let’s fetch the employee having id ObjectId(“5f20577536c73fc3e870fda3”), run the following command to fetch it. You can use pretty() to print the output in more readable format.

Command: db.collectionName.find({_id : })

Example: db.employees.find({_id:ObjectId(“5f20577536c73fc3e870fdb6”)})

With pretty print

Command: db.collectionName.find({_id : }).pretty()

Example: db.employees.find({_id:ObjectId(“5f20577536c73fc3e870fdb6”)}).pretty()

 db.employees.find({_id: ObjectId("5f20577536c73fc3e870fdb6")}).pretty()
{
        "_id" : ObjectId("5f20577536c73fc3e870fdb6"),
        "gender" : "female",
        "name" : {
                "title" : "mademoiselle",
                "first" : "delia",
                "last" : "durand"
        },
        "location" : {
                "street" : "6735 rue abel-hovelacque",
                "city" : "fontaines-sur-grandson",
                "state" : "appenzell ausserrhoden",
                "postcode" : 6137,
                "coordinates" : {
                        "latitude" : "-65.0877",
                        "longitude" : "-90.4049"
                },
                "timezone" : {
                        "offset" : "+2:00",
                        "description" : "Kaliningrad, South Africa"
                }
        },
        "email" : "delia.durand@example.com",
        "login" : {
                "uuid" : "6c4ea050-eca4-4809-8024-96a98f655553",
                "username" : "purplebear663",
                "password" : "sparky1",
                "salt" : "rzU1EPXV",
                "md5" : "a9198f953f34daf7b461b6065734d13b",
                "sha1" : "43c50f99742937b3ddd3f9ec0863924741b408c9",
                "sha256" : "63da5442d2a4d2ca02e0b3bb138e28760aa732258e35de102c8fd652c48721ea"
        },
        "dob" : {
                "date" : "1966-08-03T09:22:41Z",
                "age" : 52
        },
        "registered" : {
                "date" : "2009-05-28T19:09:24Z",
                "age" : 9
        },
        "phone" : "(166)-728-8912",
        "cell" : "(301)-529-4162",
        "id" : {
                "name" : "AVS",
                "value" : "756.5746.5832.39"
        },
        "picture" : {
                "large" : "https://randomuser.me/api/portraits/women/91.jpg",
                "medium" : "https://randomuser.me/api/portraits/med/women/91.jpg",
                "thumbnail" : "https://randomuser.me/api/portraits/thumb/women/91.jpg"
        },
        "nat" : "CH"
}

Mongodb findone

The findOne() method Return the single document if the filter is passed it will get the matching first document if not it will return the first document from the collection.

Command: db.collectionName.findOne()

Example: db.employees.findOne()

Mongodb find

The find() returns a cursor object that points to any documents that match the specified query filters. Using the cursor object, we can further manipulate the result.  Like limiting and sorting the data, converting the result into the array and iterates the cursor, and returns a Promise that resolves to the next document in the cursor. If the cursor is exhausted, the promise resolves to undefine.

Command: db.collectionName.find()

Example: db.employees.find()

When you run the above commands, you can see Type “it” for more at the end of the result if there is enough data. If you type it, it will fetch the next set of data from the database.

Mongodb find with limit

The limit () is used to specify the maximum number of documents to fetch in the query result set. If the result set contains more documents than the specified limit, the cursor will return documents in order up to the limit.

Remember, you can’t call limit() method after retrieving one or more documents using cursor.next() or cursor.toArray().

Command: db.collectionName.find().limti()

Example: db.employees.find().limit(5)

 > db.employees.find().limit(4)

{ "_id" : ObjectId("5f20577536c73fc3e870fda4"), "gender" : "male", "name" : { "title" : "mr", "first" : "harvey", "last" : "chambers" }, "location" : { "street" : "3287 high street", "city" : "carlow", "state" : "wexford", "postcode" : 47671, "coordinates" : { "latitude" : "-22.5329", "longitude" : "168.9462" }, "timezone" : { "offset" : "+5:00", "description" : "Ekaterinburg, Islamabad, Karachi, Tashkent" } }, "email" : "harvey.chambers@example.com", "login" : { "uuid" : "8f583f57-c999-4a5d-a8c1-d913b574c082", "username" : "greenrabbit148", "password" : "june", "salt" : "dAsaXJGK", "md5" : "e3759db2391b798ffea2cc168e1280fd", "sha1" : "a3e77fd5fdd75e3b173ceec6c3c1bbe5e83540cc", "sha256" : "7564eac1899234d5902fadfb995303a58370232f54bee6adb26e25394e2ffddd" }, "dob" : { "date" : "1988-05-27T00:14:03Z", "age" : 30 }, "registered" : { "date" : "2007-03-11T06:20:19Z", "age" : 11 }, "phone" : "061-265-5188", "cell" : "081-146-8382", "id" : { "name" : "PPS", "value" : "5608572T" }, "picture" : { "large" : "https://randomuser.me/api/portraits/men/82.jpg", "medium" : "https://randomuser.me/api/portraits/med/men/82.jpg", "thumbnail" : "https://randomuser.me/api/portraits/thumb/men/82.jpg" }, "nat" : "IE" }
{ "_id" : ObjectId("5f20577536c73fc3e870fda5"), "gender" : "male", "name" : { "title" : "mr", "first" : "victor", "last" : "pedersen" }, "location" : { "street" : "2156 stenbjergvej", "city" : "billum", "state" : "nordjylland", "postcode" : 56649, "coordinates" : { "latitude" : "-29.8113", "longitude" : "-31.0208" }, "timezone" : { "offset" : "+5:30", "description" : "Bombay, Calcutta, Madras, New Delhi" } }, "email" : "victor.pedersen@example.com", "login" : { "uuid" : "fbb3c298-2cea-4415-84d1-74233525c325", "username" : "smallbutterfly536", "password" : "down", "salt" : "iW5QrgwW", "md5" : "3cc8b8a4d69321a408cd46174e163594", "sha1" : "681c0353b34fae08422686eea190e1c09472fc1f", "sha256" : "eb5251e929c56dfd19fc597123ed6ec2d0130a2c3c1bf8fc9c2ff8f29830a3b7" }, "dob" : { "date" : "1959-02-19T23:56:23Z", "age" : 59 }, "registered" : { "date" : "2004-07-07T22:37:39Z", "age" : 14 }, "phone" : "23138213", "cell" : "30393606", "id" : { "name" : "CPR", "value" : "506102-2208" }, "picture" : { "large" : "https://randomuser.me/api/portraits/men/23.jpg", "medium" : "https://randomuser.me/api/portraits/med/men/23.jpg", "thumbnail" : "https://randomuser.me/api/portraits/thumb/men/23.jpg" }, "nat" : "DK" }
{ "_id" : ObjectId("5f20577536c73fc3e870fda6"), "gender" : "male", "name" : { "title" : "mr", "first" : "elijah", "last" : "lewis" }, "location" : { "street" : "2623 paddock way", "city" : "virginia beach", "state" : "wyoming", "postcode" : 54880, "coordinates" : { "latitude" : "-42.6128", "longitude" : "-18.5996" }, "timezone" : { "offset" : "+3:30", "description" : "Tehran" } }, "email" : "elijah.lewis@example.com", "login" : { "uuid" : "2292b7c7-a9bf-4341-abbd-c5841444ab6e", "username" : "angrygorilla267", "password" : "toonarmy", "salt" : "DUtMcvWR", "md5" : "258eaa742373ee70976d53d1b84d4764", "sha1" : "62f168f38fa3f6efbd815b58518775d3c6cf0080", "sha256" : "a4ab496047b9de7df39adbdabfecc813b8da428087029c94c2b748cef092f85e" }, "dob" : { "date" : "1986-03-29T06:40:18Z", "age" : 32 }, "registered" : { "date" : "2007-12-24T10:32:11Z", "age" : 10 }, "phone" : "(187)-486-3727", "cell" : "(986)-974-0857", "id" : { "name" : "SSN", "value" : "127-66-9786" }, "picture" : { "large" : "https://randomuser.me/api/portraits/men/57.jpg", "medium" : "https://randomuser.me/api/portraits/med/men/57.jpg", "thumbnail" : "https://randomuser.me/api/portraits/thumb/men/57.jpg" }, "nat" : "US" }
{ "_id" : ObjectId("5f20577536c73fc3e870fda7"), "gender" : "female", "name" : { "title" : "mrs", "first" : "olav", "last" : "oehme" }, "location" : { "street" : "gartenstraße 64", "city" : "nastätten", "state" : "mecklenburg-vorpommern", "postcode" : 93640, "coordinates" : { "latitude" : "-52.8348", "longitude" : "-67.5738" }, "timezone" : { "offset" : "-3:00", "description" : "Brazil, Buenos Aires, Georgetown" } }, "email" : "olav.oehme@example.com", "login" : { "uuid" : "2608c05c-8951-4aee-bcd2-f598c80f32bb", "username" : "heavypeacock371", "password" : "silent", "salt" : "E6R29k0e", "md5" : "587f4392dc06a9fb69a52eae94fd32f2", "sha1" : "82eba68b1fe2407281da5787b9b89505c663b587", "sha256" : "304034638901015d8a7b2fd43530fffc4c7d621ccfab98de935d9c8387198796" }, "dob" : { "date" : "1960-11-28T23:07:18Z", "age" : 57 }, "registered" : { "date" : "2011-05-31T00:24:05Z", "age" : 7 }, "phone" : "0748-6607336", "cell" : "0176-5787554", "id" : { "name" : "", "value" : null }, "picture" : { "large" : "https://randomuser.me/api/portraits/women/6.jpg", "medium" : "https://randomuser.me/api/portraits/med/women/6.jpg", "thumbnail" : "https://randomuser.me/api/portraits/thumb/women/6.jpg" }, "nat" : "DE" }
>

Mongodb Sort

The sort() method of the cursor is used to sorts documents in the result set according to the sorting filter. Sort documents specify one or more fields to sort on. The value of each field indicates whether MongoDB should sort it in ascending (1) or descending (-1) order.

Command: db.collectionName.find().sort({ })

Example: db.employees.find().sort({_id:-1})

Mongodb Projection

Generally, the find() or findOne() method returns the entire document with the _id. But in some scenarios, you may wish to fetch only some of the fields from the entire document. For example, from the employees, we want to fetch all the employee’s names only or we want to fetch username and password, and so on.

Here Projection helps us in filtering the output data based on the input given. So, the basic rule for applying projection is to use 1 to include any record in out and 0 to exclude.

Command: db.collectionName.find({< filter fields leave it like {} if no filter >},{})

Example: db.employees.find({},{email:1})

>
db.employees.find({},{email:1})
{ "_id" : ObjectId("5f20577536c73fc3e870fda4"), "email" : "harvey.chambers@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fda5"), "email" : "victor.pedersen@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fda6"), "email" : "elijah.lewis@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fda7"), "email" : "olav.oehme@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fda8"), "email" : "carl.jacobs@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fda9"), "email" : "madeleine.till@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdaa"), "email" : "shona.kemperman@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdab"), "email" : "louise.graham@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdac"), "email" : "zachary.lo@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdad"), "email" : "isolino.viana@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdae"), "email" : "katie.welch@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdaf"), "email" : "sandra.lorenzo@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdb0"), "email" : "mestan.kaplangı@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdb2"), "email" : "gideon.vandrongelen@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdb3"), "email" : "maeva.wilson@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdb4"), "email" : "anaëlle.adam@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdb5"), "email" : "anne.ruiz@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fdb6"), "email" : "delia.durand@example.com" }
Type "it" for more

I have explained above that use 1 to apply projection to fetch only that field or fields. But here we are getting _id as well. One thing to remember is that if you don’t want _id in the result you must explicitly mention it with 0 (zero) in projection like below.

Example: db.employees.find({},{email:1,_id:0})

> db.employees.find({},{email:1,_id:0})
{ "email" : "harvey.chambers@example.com" }
{ "email" : "victor.pedersen@example.com" }
{ "email" : "elijah.lewis@example.com" }
{ "email" : "olav.oehme@example.com" }
{ "email" : "carl.jacobs@example.com" }
{ "email" : "madeleine.till@example.com" }
{ "email" : "shona.kemperman@example.com" }
{ "email" : "louise.graham@example.com" }
{ "email" : "zachary.lo@example.com" }
{ "email" : "isolino.viana@example.com" }
{ "email" : "katie.welch@example.com" }
{ "email" : "sandra.lorenzo@example.com" }
{ "email" : "mestan.kaplangı@example.com" }
{ "email" : "gideon.vandrongelen@example.com" }
{ "email" : "maeva.wilson@example.com" }
{ "email" : "anaëlle.adam@example.com" }
{ "email" : "anne.ruiz@example.com" }
{ "email" : "delia.durand@example.com" }
Type "it" for more

Mongodb find count

The count() is used to fetch the count of documents inside a collection. If a filter is passed in find() it will return count documents matched with the input filter otherwise it will return the count of all the documents.

Command: db.collectionName.find({}).count()

Example: db.employees.find({}).count()

Mongodb findone latest

To get the latest record from the database we can use _id with find() method with the help of limit (1) like below.

Command: db.collectionName.find().sort({_id:-1}).limit(1)

Example: db.employees.find().sort({_id:-1}).limit(1)

But this can hit the performance if the underlying data is huge. In such a case we can use another approach like below.

Command: db.collectionName.find().limit(1).sort({$natural:-1})

here $natural:-1 means the order opposite of the one that records are inserted in.

Example: db.employees.find().limit(1).sort({$natural:-1})

Mongodb find like

Sometimes there can be a requirement to fetch the data from MongoDB using some keywords or with the data we don’t have completely. Something like the like operator in SQL. In such cases, we can use regex to fetch the data.

Command: db.collectionName.fin({property: // })

Example: db.employees.find({email:/vand/},{email:1})

> db.employees.find({email:/vand/},{email:1})
{ "_id" : ObjectId("5f20577536c73fc3e870fdb2"), "email" : "gideon.vandrongelen@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fede"), "email" : "melvyn.vanderent@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870fee3"), "email" : "querijn.vandenboorn@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870ff31"), "email" : "vanda.novaes@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e870ffb7"), "email" : "sanjeev.vanderborgh@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e8710265"), "email" : "nurullah.vanderkaaden@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e87102d8"), "email" : "pedram.vandenmunckhof@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e871032e"), "email" : "warner.vandenouweland@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e8710397"), "email" : "hulya.vandoremalen@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e87103f6"), "email" : "solomon.vanderheijde@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e8710495"), "email" : "dicky.vandermaat@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e871058b"), "email" : "jonno.vanderwal@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e8710699"), "email" : "tulay.vanderarend@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e871087d"), "email" : "mathys.vandelft@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e8710a5e"), "email" : "juul.vanderhaar@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e8710ab8"), "email" : "nur.vandiggelen@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e8710b56"), "email" : "patriek.vandepeppel@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e8710b87"), "email" : "remy.vandegeijn@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e8710bb0"), "email" : "karine.vandenbos@example.com" }
{ "_id" : ObjectId("5f20577536c73fc3e8710cba"), "email" : "halil.vanduinkerken@example.com" }
Type "it" for more

This is one of the ways of using regex. You can try other regex options as well.

Mongodb find in array

While querying the data and using a filter on an array if we use db.find({tags: ‘hello’}) – it will return all the collections having array tags and the array contains a hello. But if you want to fetch only those documents which only have tags hello then we have to pass it inside the square bracket like db.find({tags [‘hello’]}).

Similarly, we can use in and not in like below.

db.find({tags : {$in : [‘hello’,’goodbye’]}}) — to use in keyword
db.find({tags : {$nin : [‘hello’,’goodbye’]}}) — to use not in keyword

Example: 

>
 db.products.find()
{ "_id" : ObjectId("5f2149f5bff8019e3cd633ad"), "productName" : "Product 2", "price" : 199, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer", "winter" ] }
{ "_id" : ObjectId("5f2149f5bff8019e3cd633ae"), "productName" : "Product 3", "price" : 399, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer", "monsoon" ] }
{ "_id" : ObjectId("5f2149f5bff8019e3cd633af"), "productName" : "Product 4", "price" : 499, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer" ] }
{ "_id" : ObjectId("5f2149f5bff8019e3cd633b0"), "productName" : "Product 5", "price" : 599, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "winter" ] }


> db.products.find({usedIn: 'summer'})
{ "_id" : ObjectId("5f2149f5bff8019e3cd633ad"), "productName" : "Product 2", "price" : 199, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer", "winter" ] }
{ "_id" : ObjectId("5f2149f5bff8019e3cd633ae"), "productName" : "Product 3", "price" : 399, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer", "monsoon" ] }
{ "_id" : ObjectId("5f2149f5bff8019e3cd633af"), "productName" : "Product 4", "price" : 499, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer" ] }


> db.products.find({usedIn: ['summer']})
{ "_id" : ObjectId("5f2149f5bff8019e3cd633af"), "productName" : "Product 4", "price" : 499, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer" ] }

> db.products.find({usedIn: {$in: ['summer']}})
{ "_id" : ObjectId("5f2149f5bff8019e3cd633ad"), "productName" : "Product 2", "price" : 199, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer", "winter" ] }
{ "_id" : ObjectId("5f2149f5bff8019e3cd633ae"), "productName" : "Product 3", "price" : 399, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer", "monsoon" ] }
{ "_id" : ObjectId("5f2149f5bff8019e3cd633af"), "productName" : "Product 4", "price" : 499, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer" ] }


> db.products.find({usedIn: {$in: ['summer','mansoon']}})
{ "_id" : ObjectId("5f2149f5bff8019e3cd633ad"), "productName" : "Product 2", "price" : 199, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer", "winter" ] }
{ "_id" : ObjectId("5f2149f5bff8019e3cd633ae"), "productName" : "Product 3", "price" : 399, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer", "monsoon" ] }
{ "_id" : ObjectId("5f2149f5bff8019e3cd633af"), "productName" : "Product 4", "price" : 499, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer" ] }


> db.products.find({usedIn: {$in: ['winter','mansoon']}})
{ "_id" : ObjectId("5f2149f5bff8019e3cd633ad"), "productName" : "Product 2", "price" : 199, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer", "winter" ] }
{ "_id" : ObjectId("5f2149f5bff8019e3cd633b0"), "productName" : "Product 5", "price" : 599, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "winter" ] }


> db.products.find({usedIn: {$nin: ['winter','mansoon']}})
{ "_id" : ObjectId("5f2149f5bff8019e3cd633ae"), "productName" : "Product 3", "price" : 399, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer", "monsoon" ] }
{ "_id" : ObjectId("5f2149f5bff8019e3cd633af"), "productName" : "Product 4", "price" : 499, "receivedOn" : ISODate("2020-07-29T10:05:41.106Z"), "usedIn" : [ "summer" ] }

Mongodb cursor to toArray

The toArray() method iterates the cursor to exhaustion and returns a Promise that resolves to an array that contains all of the iterated documents.

Command: db.collectionName.find().toArray()

Example: db.employees.find().toArray()

That’s it in this post, here we discussed various ways to fetch the data from MongoDB, how to use projection, limiting the result, sorting the data, etc.

if you are starting with MongoDB. you can check my post on Setting up MongoDB and an introduction to shell

Reference https://docs.mongodb.com/realm/mongodb/

You can share other ways to achieve the above requirements or if you know better ways to do it.

Happy Learning !!

Leave a Comment