Reputation: 396
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.
Upvotes: 10
Views: 14989
Reputation: 3048
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.
Upvotes: 18