I have an employee
collection like this
Company. Ceo. Employees
Sdr. Siva. 1-200
Datamatica. Durga. 200-400
Big. Mouli. 50-100
After using
db.employee.find({Employees : {$gte : 200}})
I don't get any data. The Employees
field type is a string.
As japrescott stated, you should split the Employees
field into two separate fields (employees_from, employees_to) of type Number
and then query like this:
db.employee.find({employees_from : {$gte : 200}})
For migration you could use mongo's map reduce to split the current Employees
into two separate field and add these to your documents. Afterwards you can delete the Employees
field.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.