Filtering mongo document using $lt operator under Employee_Detail collection.
Example:
[{"_id" : ObjectId("60179dd62381fc69d5f1c599"),"Emp_Name" : "Andrew","Emp_Age" : NumberInt(22),"Emp_Salary" : NumberInt(34000),"Emp_Joining_Date" : ISODate("2020-07-03T18:30:00.000+0000")}{"_id" : ObjectId("60179dd62381fc69d5f1c59a"),"Emp_Name" : "Sam","Emp_Age" : NumberInt(34),"Emp_Salary" : NumberInt(34000),"Emp_Joining_Date" : ISODate("2020-07-03T18:30:00.000+0000")}]
Approach
Query: Find employee having age less than 25.
db.Employee_Detail.aggregate({$match:{"Emp_Age":{$lt:25}}});
Output:
[{"_id" : ObjectId("60179dd62381fc69d5f1c599"),"Emp_Name" : "Andrew","Emp_Age" : NumberInt(22),"Emp_Salary" : NumberInt(34000),"Emp_Joining_Date" : ISODate("2020-07-03T18:30:00.000+0000")}]
No comments:
Post a Comment