[英]Mongodb greater than query
I have an employee
collection like this 我有这样的
employee
集合
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. Employees
字段类型是一个字符串。
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: 正如japrescott所说,您应该将
Employees
字段拆分为Number
类型的两个单独字段(employees_from,employees_to),然后像这样查询:
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. 对于迁移,您可以使用mongo的map reduce将当前
Employees
拆分为两个单独的字段,并将这些字段添加到您的文档中。 Afterwards you can delete the Employees
field. 之后,您可以删除
Employees
字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.