当我有两个像这样的MongoDB文档时...
db.test.insert( {"value" : "10123"} );
db.test.insert( {"value" : "160"} );
查询的结果如下:
db.test.find({"value" :{$gt : "12"} });
是
{ "_id" : ObjectId("4c6d1b92304326161b678b89"), "value" : "160" }
很明显,会进行字符串比较,因此不会返回我的第一个值.
比如:
db.test.find({ (int) "value" :{$gt : 12} });
那太好了.像这样的问题
db.test.find({"value" :{$gt : 12} }); // without the quotes around "12"
不返回任何内容.