$gte

$gte

Syntax: {field: {$gte: value} }

$gte selects the documents where the value of the field is greater than or equal to (i.e. >=) a specified value (e.g. value.)选择field值大于或等于(即>=)指定值(例如value)的文档

For most data types, comparison operators only perform comparisons on fields where the BSON type matches the query value’s type. 对于大多数数据类型,比较运算符仅对BSON类型与查询值类型匹配的字段执行比较。MongoDB supports limited cross-BSON comparison through Type Bracketing.MongoDB通过类型括号支持有限的交叉BSON比较。

Consider the following example:考虑下面的例子:

db.inventory.find( { qty: { $gte: 20 } } )

This query would select all documents in inventory where the qty field value is greater than or equal to 20.此查询将选择inventoryqty字段值大于或等于20的所有单据。

Consider the following example which uses the $gte operator with a field from an embedded document:考虑下面的示例,该示例使用$gte运算符和来自嵌入文档的字段:

db.inventory.update( { "carrier.fee": { $gte: 2 } }, { $set: { price: 9.99 } } )

This update() operation will set the value of the price field that contain the embedded document carrier whose fee field value is greater than or equal to 2.update()操作将设置包含fee字段值大于或等于2的嵌入式文档carrierprice字段的值。

See also参阅

find(), update(), $set.