Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (50.2k points)

I have an employee collection like this

image

After using

db.employee.find({Employees : {$gte : 200}}) 

I don't get any data. The Employees field type is a string.

1 Answer

0 votes
by (108k points)
edited by

First things first you cannot have a range inside your string datatype. You have to split your Employees’ field into two separate fields(employees_from and employees_to). For performing the above implementation, you can use Mongo’s MapReduce for splitting the field into two separate fields. Then you can read your data with the help of the following code:

db.employee.find({employees_from : {$gte : 200}})

If you want to learn more about MongoDB then go through this MongoDB course for more insights.

In addition, check out this Full Stack Developer Online Course to help you enhance your skills.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Mar 15, 2020 in Web Technology by ashely (50.2k points)
0 votes
1 answer
asked Mar 14, 2020 in Web Technology by ashely (50.2k points)
0 votes
1 answer
asked Mar 14, 2020 in Web Technology by ashely (50.2k points)

Browse Categories

...