Skip to content
 
 

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MongoDB Complete Course

https://www.youtube.com/@codewithkarthik

How to Configure MongoDB

Step 1

Install MongoDB Database

Download MongoDB - https://www.mongodb.com/try/download/community

Step 2

Install MongoDB Shell

Download MongoDB Shell - https://www.mongodb.com/try/download/shell

Step 3

Configure Enviroment Variables As Per Tutorial Video - https://youtu.be/0zwYbudzaJc


No-SQL Commands

Connecting to MongoDB Server

Step 1: Open command prompt(cmd) in your system
Step 2: Type 'mongosh' then hit enter key

Show database

The following command is used to show avaliable database list.
show dbs

Command to connect database

The following command is used to connect with database even if database is not exists it will create new database.
#Syntax
use [database name]
#Example
use maxishop

Creating Collection & Document

#Syntax
db.collectionName.insertOne({document})
#Example
db.products.insertOne({name:'Iphone 15',price:80000})

To get all the data from the collection

#Syntax
db.collectionName.find()
#Example
db.products.find()

#For Older version
db.products.find().pretty()

Creating Document with different schema or structure

#Example
db.products.insertOne({name:'Mac Book Pro',price:120000,brand:'Apple'})
db.products.insertOne({name:'Samsung Galaxy s24 Ultra',price:120000,brand:'Samsung'})
db.products.insertOne({name:'Bravia 43 inch 4k',price:120000,brand:'Samsung',productType:'TV'})

Embedded Document

Instead Document in Collections
db.products.insertOne({name:'Lenovo Legion',price:120000,brand:'Lenovo',productType:'Laptop',specification:{ram:'16 GB',processor:'i7 13th Gen',storageType:'SSD',storageSize:'1 TB'}})
#for easy understanding
db.products
  .insertOne(
    {
      name:'Lenovo Legion',
      price:120000,
      brand:'Lenovo',
      productType:'Laptop'
      specification:{
        ram:'16 GB',
        processor: 'i7 13th Gen',
        storageType:'SSD',
        storageSize: '1 TB'
      }
    })

you can also provide your own id as well like the following example.

note: Id should be unique, no duplicate key
db.products.insertOne({_id:'AX1000001',name:'MSI Katna 15',price:98000,brand:'MSI',productType:'Laptop',specification:{ram:'16 GB',processor:'i7 12th Gen',storageType:'SSD',storageSize:'512 GB'}})
#for easy understanding
db.products
  .insertOne(
    {
      _id:'AX1000001'
      name:'MSI Katna 15',
      price:98000,
      brand:'MSI',
      productType:'Laptop'
      specification:{
        ram:'16 GB',
        processor: 'i7 12th Gen',
        storageType:'SSD',
        storageSize: '512 GB'
      }
    })

Datatypes

use temp
db.orders.insertOne({quantity:50,totalAmount:1234567890123456,discount:0.10,status:'warehouse',isActive:true,details:{address:'Chennai,Tamil Nadu,India',pincode:600044},phoneNo: [123456789,987654321],orderDate:new Date(),createdAt:new Timestamp()})
db.orders.find()
db.orders.drop()
db.orders.insertOne({quantity:NumberInt(50),totalAmount:NumberLong('1234567890123456'),discount:0.10,status:'warehouse',isActive:true,details:{address:'Chennai,Tamil Nadu,India',pincode:NumberInt(600044)},phoneNo: [NumberLong('123456789'),NumberLong('987654321')],orderDate:new Date(),createdAt:new Timestamp()})
db.orders.find()

CRUD Operation

  1. Create

    • insertOne(data,options)
    • insertMany(data,options)
  2. Read

    • find(filter,options)
    • findOne(filter,options) #first matching document
  3. Update

    • updateOne(filter,data,options)
    • updateMany(filter,data,options)
    • replaceOne(filter,data,options)
  4. Delete

    • deleteOne(filter,options)
    • deleteMany(filter,options)

Create Document In Collection

Inserting Single Record

db.products.insertOne({name:'Nothing Phone 2a',price:56000,brand:'Nothing',productType:'Mobile'})
db.products.insertOne({_id:'AX1000002',name:'MSI Katna 15 Pro',price:130000,brand:'MSI',productType:'Laptop',specification:{ram:'16 GB',processor:'i7 13th Gen',storageType:'SSD',storageSize:'1 TB'}})
#for easy understanding
db.products
  .insertOne(
    {
      _id:'AX1000002'
      name:'MSI Katna 15 Pro',
      price:130000,
      brand:'MSI',
      productType:'Laptop'
      specification:{
        ram:"16 GB",
        processor: 'i7 13th Gen',
        storageType:'SSD',
        storageSize: '1 TB'
      }
    })

Inserting Many Records

db.products.insertMany([{name:'Iphone 14',price:75000,brand:'Apple'},{name:'Samsung Galaxy A50',price:54000,brand:'Samsung'}])

Read document from collection

db.products.find()
Filter
db.products.find({brand:'Apple'})
db.products.findOne({brand:'Apple'})

Update document in collection

Updating Single Record

db.products.updateOne({name:'Mac Book Pro'},{$set:{productType:'Laptop'}})
db.products.updateOne({name:'Samsung Galaxy s24 Ultra'},{$set:{price:93000}})
db.products.updateOne({name:'Bravia 43 inch 4k'},{$set:{price:45000}})
db.products.updateOne({name:'Iphone 15'},{$set:{brand:'Apple',productType:'Mobile'}})

Updating Many Records

db.products.updateMany({_id:{$in:[ObjectId('66695c4aa52b865509cdcdf8'),ObjectId('66695c8ba52b865509cdcdfd')]}},{$set:{productType:"Mobile"}})

Replacing The Document

 db.products.replaceOne({_id:ObjectId('66695c8ba52b865509cdcdfc')},{name:"Iphone 14 Pro Max",price:115000,brand:'Apple',productType:'Mobile'})

Delete document from collection

Deleting Single Record

# the following command will delete the 1st document with matched filter
db.products.deleteOne({brand:'Apple'})
db.products.deleteOne({brand:'Samsung'})
db.products.deleteOne({productType:'Laptop'})
# the following command will delete document based on Id
db.products.deleteOne({_id:'AX1000002'})

Deleting Many Record

# the following command will delete document many at same time
db.products.deleteMany({productType:'Laptop'})
db.products.deleteMany({})

Deleting Collection

db.products.drop()

Deleting Database

db.dropDatabase()

Convert Json to Json minifier

Link - https://codebeautify.org/jsonminifier

Prepare Data

Products
db.products.insertMany([{"name":"Iphone 15","price":80000,"brand":"Apple","productType":"Mobile"},{"name":"Iphone 14 Pro Max","price":115000,"brand":"Apple","productType":"Mobile"},{"name":"Samsung Galaxy A50","price":54000,"brand":"Samsung","productType":"Mobile"},{"name":"Nothing Phone 2a","price":56000,"brand":"Nothing","productType":"Mobile"},{"name":"Samsung Galaxy s24 Ultra","price":93000,"brand":"Samsung","productType":"Mobile"},{"name":"Bravia 43 inch 4k","price":45000,"brand":"Samsung","productType":"TV"},{"name":"Mac Book Pro","price":120000,"brand":"Apple","productType":"Laptop","specification":{"ram":"8 GB","processor":"M1","storageType":"SSD","storageSize":"512 GB"}},{"name":"Lenovo Legion","price":120000,"brand":"Lenovo","productType":"Laptop","specification":{"ram":"16 GB","processor":"i7 13th Gen","storageType":"SSD","storageSize":"1 TB"}},{"name":"MSI Katna 15","price":98000,"brand":"MSI","productType":"Laptop","specification":{"ram":"16 GB","processor":"i7 12th Gen","storageType":"SSD","storageSize":"512 GB"}},{"name":"MSI Katna 15 Pro","price":130000,"brand":"MSI","productType":"Laptop","specification":{"ram":"16 GB","processor":"i7 13th Gen","storageType":"SSD","storageSize":"1 TB"}}])
Customers
 db.customers.insertMany([{"name":"Amit Sharma","age":29,"gender":"Male"},{"name":"Priya Singh","age":30,"gender":"Female"},{"name":"Ravi Verma","age":35,"gender":"Male"},{"name":"Sandeep Kumar","age":28,"gender":"Male"},{"name":"Anita Joshi","age":30,"gender":"Female"},{"name":"Anjali Patel","age":27,"gender":"Female"},{"name":"Dr.Rajesh Mehta","age":47,"gender":"Male"},{"name":"Seema Gupta","age":33,"gender":"Female"},{"name":"Aarti Chawla","age":29,"gender":"Female"},{"name":"Rohit Desai","age":41,"gender":"Male"},{"name":"Karandeep Alun","age":48,"gender":"Male"},{"name":"Neha Singh","age":39,"gender":"Female"},{"name":"Arjun Reddy","age":22,"gender":"Male"},{"name":"Vikram Sharma","age":44,"gender":"Male"},{"name":"Aman Khan","age":41,"gender":"Male"},{"name":"Meera Iyer","age":"35","gender":"Female"},{"name":"Nidhi Kapoor","age":27,"gender":"Female"},{"name":"Arjun Gupta","age":35,"gender":"Male"},{"name":"Kiran Naik","age":53,"gender":"Male"},{"name":"Bharat Rao","age":68,"gender":"Male"},{"name":"Ramesh Patel","age":38,"gender":"Male"}])

Cursor Object

#find will not give all records
db.customers.find()
#it to show remaining records

To see all the data use following commands

db.customers.find().toArray()
db.customers.find().forEach((customersData)=> {printjson(customersData)})

Projection

db.customers.find({},{name:1})
db.products.find({},{name:1,price:1})

To ignore id

db.products.find({},{_id:0,name:1,price:1})
db.products.find({},{_id:0,name:1,price:1,brand:1})

Array

db.customers.updateOne({name:'Arjun Reddy'},{$set:{contactNo:[5987452368,8536547859]}})
db.customers.updateOne({name:'Seema Gupta'},{$set:{hobbies:['cooking','sports','singing']}})
db.customers.updateMany({name:{$in:['Neha Singh','Vikram Sharma','Arjun Gupta']}},{$set:{hobbies:['travel','sports']}})
db.customers.updateMany({name:{$in:['Meera Iyer','Nidhi Kapoor','Bharat Rao']}},{$set:{hobbies:['cooking','sports']}})
db.products.updateMany({},{$set:{categories:['electronics']}})

Delete and Prepare dataset

db.products.deleteMany({})
db.products.insertMany([{"name":"Iphone 15","price":80000,"brand":"Apple","productType":"Mobile","categories":["electronics"]},{"name":"Iphone 14 Pro Max","price":115000,"brand":"Apple","productType":"Mobile","categories":["electronics"]},{"name":"Samsung Galaxy A50","price":54000,"brand":"Samsung","productType":"Mobile","categories":["electronics"]},{"name":"Nothing Phone 2a","price":56000,"brand":"Nothing","productType":"Mobile","categories":["electronics"]},{"name":"Samsung Galaxy s24 Ultra","price":93000,"brand":"Samsung","productType":"Mobile","categories":["electronics"]},{"name":"Bravia 43 inch 4k","price":45000,"brand":"Samsung","productType":"TV","categories":["electronics"]},{"name":"Mac Book Pro","price":120000,"brand":"Apple","productType":"Laptop","specification":{"ram":"8 GB","processor":"M1","storageType":"SSD","storageSize":"512 GB"},"categories":["electronics"]},{"name":"Lenovo Legion","price":120000,"brand":"Lenovo","productType":"Laptop","specification":{"ram":"16 GB","processor":"i7 13th Gen","storageType":"SSD","storageSize":"1 TB"},"categories":["electronics"]},{"name":"MSI Katna 15","price":98000,"brand":"MSI","productType":"Laptop","specification":{"ram":"16 GB","processor":"i7 12th Gen","storageType":"SSD","storageSize":"512 GB"},"categories":["electronics"]},{"name":"MSI Katna 15 Pro","price":130000,"brand":"MSI","productType":"Laptop","specification":{"ram":"16 GB","processor":"i7 13th Gen","storageType":"SSD","storageSize":"1 TB"},"categories":["electronics"]},{"_id":"666982f9132be8d964cdce53","name":"Samsung RT28T3022S8","price":25000,"brand":"Samsung","productType":"Refrigerator","specification":{"capacity":"253L","energyRating":"3 Star"},"categories":["kitchen_appliances"]},{"_id":"666982f9132be8d964cdce54","name":"LG MC2846BG","price":15000,"brand":"LG","productType":"Microwave Oven","specification":{"type":"Convection","capacity":"28L"},"categories":["kitchen_appliances"]},{"_id":"666982f9132be8d964cdce55","name":"Whirlpool IF278","price":22000,"brand":"Whirlpool","productType":"Refrigerator","specification":{"capacity":"265L","energyRating":"4 Star"},"categories":["kitchen_appliances"]},{"_id":"666982f9132be8d964cdce56","name":"IFB 30BRC2","price":20000,"brand":"IFB","productType":"Microwave Oven","specification":{"type":"Convection","capacity":"30L"},"categories":["kitchen_appliances"]},{"_id":"666982f9132be8d964cdce57","name":"Samsung WW60R20GLMA","price":28000,"brand":"Samsung","productType":"Washing Machine","specification":{"capacity":"6 kg","type":"Front Load"},"categories":["laundry_appliances"]},{"_id":"666982f9132be8d964cdce58","name":"LG T7281NDDLG","price":18000,"brand":"LG","productType":"Washing Machine","specification":{"capacity":"6.2 kg","type":"Top Load"},"categories":["laundry_appliances"]},{"_id":"666982f9132be8d964cdce59","name":"Philips HD6975/00","price":7000,"brand":"Philips","productType":"Oven Toaster Grill","specification":{"capacity":"25L","powerConsumption":"1500W"},"categories":["kitchen_appliances"]},{"_id":"666982f9132be8d964cdce5a","name":"Dyson V11 Absolute Pro","price":52000,"brand":"Dyson","productType":"Vacuum Cleaner","specification":{"type":"Cord-free","runTime":"60 minutes"},"categories":["home_cleaning"]},{"_id":"666982f9132be8d964cdce5b","name":"Eureka Forbes Aquaguard Marvel","price":15000,"brand":"Eureka Forbes","productType":"Water Purifier","specification":{"type":"RO+UV","storageCapacity":"8L"},"categories":["water_appliances"]},{"_id":"666982f9132be8d964cdce5c","name":"Kent Grand Plus","price":19000,"brand":"Kent","productType":"Water Purifier","specification":{"type":"RO+UV+UF","storageCapacity":"9L"},"categories":["water_appliances"]}])

Accessing Embedded Document Data

Filter by hobbies in customers
db.customers.find({hobbies:'sports'})
 db.customers.find({hobbies:'cooking'})
Finding embedded data in customers
db.customers.findOne({age:22}).contactNo
db.customers.findOne({name:'Nidhi Kapoor'}).hobbies
Filter by catgory in products
db.products.find({categories:'electronics'});
 db.products.find({categories:'kitchen_appliances'});
Fliter by embedded data in products
db.products.find({"specification.storageSize":'512 GB'})
db.products.find({"specification.storageSize":'1 TB'})
db.products.find({"specification.ram":'8 GB'})
db.products.find({'specification.energyRating':'4 Star'});

Database Methods

Status of database
db.stats()
Get current database name
db.getName()
Get collection list from current database
db.getCollectionNames()
Get collection list with more information from current database
db.getCollectionInfos()

Collection Methods

Find no of documents in collection
db.products.countDocuments()
Find distinct values from collection
db.products.distinct('categories')

Document Validation

use schoolDb
db.createCollection('staff',{
  validator:{
    $jsonSchema:{
      bsonType:'object',
      required:['name','age','email'],
      properties:{
        name:{
          bsonType:'string',
          description:'must be string and required field'
        },
        age:{
          bsonType:'int',
          description:'must be integer and required field'
        },
        email:{
          bsonType:'string',
          description:'must be string and required field'
        }
      }
    }
  }
})
db.createCollection('staffs',{validator:{$jsonSchema:{bsonType:'object',required:['name','age','email'],properties:{name:{bsonType:'string',description:'must be string and required field'},age:{bsonType:'int',description:'must be integer and required field'},email:{bsonType:'string',description:'must be string and required field'}}}}})
db.staffs.insertOne({name:'john',age:25,email:'john@gmail.com'})
db.runCommand({
  collMod:'staffs',
  validator:{
    $jsonSchema:{
      bsonType:'object',
      required:['name','email'],
      properties:{
        name:{
          bsonType:'string',
          description:'must be string and required field'
        },
        email:{
          bsonType:'string',
          description:'must be string and required field'
        }
      }
    }
  }
});
db.runCommand({collMod:'staffs',validator:{$jsonSchema:{bsonType:'object',required:['name','email'],properties:{name:{bsonType:'string',description:'must be string and required field'},email:{bsonType:'string',description:'must be string and required field'}}}}});
db.staffs.insertOne({name:'alex',email:'alex@gmail.com'})
db.staffs.find()

Operators

use maxishop

Comparison Operators

Equals
db.products.find({price:{$eq:80000}})
Greater Than
db.products.find({price:{$gt:80000}})
db.products.findOne({price:{$gt:80000}})
Greater Than or Equal
db.products.find({price:{$gte:80000}})
Less Than
db.products.find({price:{$lt:80000}})
db.products.findOne({price:{$lt:80000}})
Less Than or Equal
db.products.find({price:{$lte:80000}})
Not Equal
db.products.find({price:{$ne:80000}})
Matches any of the values in an array
 db.customers.find({hobbies:{$in:['cooking']}})
db.customers.find({hobbies:{$in:['cooking','travel']}})
Not Matched any of the values in an array
 db.customers.find({hobbies:{$nin:['cooking']}})
db.customers.find({hobbies:{$nin:['cooking','travel']}})

Logical Operators

AND
db.products.find({$and:[{price:{$gt:80000}},{brand:'Apple'}]})
OR
db.products.find({$or:[{price:{$lt:10000}},{brand:'Apple'}]})
NOR
db.products.find({$nor:[{price:{$lt:10000}},{productType:'Laptop'},{productType:'Mobile'}]})
db.products.find({$nor:[{price:{$lt:40000}},{productType:'Laptop'},{productType:'Mobile'}]})
NOT
db.products.find({price:{$not:{$gt:10000}}})

Element Operators

Exists
db.customers.find({hobbies:{$exists:false}})
db.customers.find({hobbies:{$exists:true}})
db.customers.find({$and:[{hobbies:{$exists:true}},{age:{$gt:40}}]})
db.customers.find({$and:[{hobbies:{$exists:false}},{age:{$gt:40}}]})
Type
db.customers.find({age:{$type:'string'}})
db.customers.find({age:{$type:'number'}})

Expr - expression

use personalData
db.personalData.insertMany([{category:'food',budget:400,spent:450},{category:'clothes',budget:100,spent:50},{category:'travel',budget:200,spent:650}])
 db.personalData.find({$expr:{$gt:['$spent','$budget']}})

Array Operators

use maxishop
Array Size
db.customers.find({hobbies:{$size:3}})
db.customers.find({hobbies:{$size:2}})
All
db.customers.find({hobbies:["sports","travel"]})
db.customers.find({hobbies:["travel","sports"]})
db.customers.find({hobbies:{$all:["sports","travel"]}})

Sort, Skip & Limit

Sorting the document
db.products.find().sort('price')
db.products.find().sort({'price':-1})
db.products.find({productType:'Mobile'}).sort('price')
db.products.find({productType:'Mobile'}).sort({'price':-1})
Skip the document
db.products.find({productType:'Mobile'}).sort('price').skip(2)
Limit the document
db.products.find({productType:'Mobile'}).sort('price').limit(2)
db.products.find({productType:'Mobile'}).sort({'price':-1}).skip(1).limit(2)

Example from Learning

 db.products.find({},{_id:0,name:1,'specification.ram':1}).sort({'price':-1}).limit(4)
 db.products.find({specification:{$exists:true}},{_id:0,name:1,'specification.ram':1}).sort({'price':-1}).limit(4)

CRUD Options

Create option
use temp
db.users.insertOne({_id:'UA001',name:'John wick'})
db.users.insertMany([{_id:'UA001',name:'Lisa'},{_id:'UA002',name:'Rose'}])

ordered - partial insert for valid documents

db.users.insertMany([{_id:'UA001',name:'Lisa'},{_id:'UA002',name:'Rose'}],{ordered:false})
Read Option
use maxishop

Projection

db.products.find({},{name:1})
db.products.find({},{_id:0,name:1})
 db.products.find({productType:'Laptop'},{name:1})
 db.products.find({productType:'Laptop'},{name:1,specification:1})
 db.products.find({productType:'Laptop'},{name:1,'specification.ram':1})
 db.products.find({productType:'Laptop'},{name:1,'specification.ram':1,'specification.processor':1})

Slice

db.customers.find({hobbies:{$exists:true}},{hobbies:{$slice:1}})

Slice Skip and Take

db.customers.find({hobbies:{$exists:true}},{hobbies:{$slice:[1,2]}})
Update option

Before upsert, if there is not match then changes will not happen

db.customers.updateOne({name:'Swetha'},{$set:{name:'Swetha Sri',age:25,gender:'Female',hobbies:['travel','dancing']}})

upsert

db.customers.updateOne({name:'Swetha'},{$set:{name:'Swetha Sri',age:25,gender:'Female',hobbies:['travel','dancing']}},{upsert:true})
Delete option
db.customers.find().sort('age').limit(3)
db.customers.findOneAndDelete({},{sort:{age:1}})

Relations

One to One Relation
use OrgDB
db.employees.insertOne({_id:'EMP001',name:'John Doe',postion:'Software Enginner'})
db.profiles.insertOne({employee_id:'EMP001',age:26,address:'123 Main St',phone:'555-555-5555'})

Aggregate

db.employees.aggregate([{$lookup:{from:'profiles',localField:'_id',foreignField:'employee_id',as:"personalDetails"}}])
One to Many Relation

Creating Companies

db.companies.insertMany([{_id:'CMP001',name:'Nule Soft',isMNC:true},{_id:'CMP002',name:'JexiTech',isMNC:false},{_id:'CMP003',name:'DSA Softwares',isMNC:true}])

Updateing old employee to assgin company

db.employees.updateOne({_id:'EMP001'},{$set:{company_id:'CMP001'}})

Adding More Employee with different companies

db.employees.insertMany([{_id:'EMP002',name:'Alice Smith',postion:'Product Manager',company_id:'CMP001'},{_id:'EMP003',name:'Bob Brown',postion:'UI/UX Designer',company_id:'CMP002'},{_id:'EMP004',name:'Charlie Davis',postion:'Backend Developer',company_id:'CMP001'},{_id:'EMP005',name:'Diana Evans',postion:'Frontend  Developer',company_id:'CMP001'}])
db.profiles.insertMany([{employee_id:'EMP002',age:36,address:'123 Main St',phone:'444-555-5555'},{employee_id:'EMP003',age:28,address:'123 Main St',phone:'222-333-5555'},{employee_id:'EMP004',age:37,address:'567 Main St',phone:'111-333-4444'},{employee_id:'EMP005',age:32,address:'987 Main St',phone:'111-222-8888'}])

Aggregate

db.companies.aggregate([{$lookup:{from:'employees',localField:'_id',foreignField:'company_id',as:'Employees'}}])
Many to Many Relation

Creating projects

db.projects.insertMany([{_id:'P001',name:'Project Alpha'},{_id:'P002',name:'Project Beta'}])
db.employee_projects.insertMany([{employee_id:'EMP001',project_id:'P001'},{employee_id:'EMP005',project_id:'P001'},{employee_id:'EMP003',project_id:'P001'},{employee_id:'EMP002',project_id:'P002'},{employee_id:'EMP004',project_id:'P002'},{employee_id:'EMP003',project_id:'P002'}])

Aggregate

db.projects.aggregate([{$lookup:{from:'employee_projects',localField:'_id',foreignField:'project_id',as:'employee_projects'}}])
 db.projects.aggregate([{$lookup:{from:'employee_projects',localField:'_id',foreignField:'project_id',as:'employee_projects'}},{$unwind:"$employee_projects"},{$lookup:{from:'employees',localField:'employee_projects.employee_id',foreignField:'_id',as:'employees'}},{$unwind:'$employees'},{$group:{_id:'$_id',name:{$first:'$name'},employees:{$push:'$employees'}}},{$project:{_id:0,name:1,employees:1}}])
db.projects.aggregate([{$lookup:{from:'employee_projects',localField:'_id',foreignField:'project_id',as:'employee_projects'}},{$unwind:"$employee_projects"},{$lookup:{from:'employees',localField:'employee_projects.employee_id',foreignField:'_id',as:'employees'}},{$unwind:'$employees'},{$group:{_id:'$_id',name:{$first:'$name'},employees:{$push:{employee_id:'$employees._id',name:'$employees.name'}}}},{$project:{_id:1,name:1,employees:1}}])

Copyrights to codewithkarthik

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors