$lte
¶Syntax: { field: { $lte: value} }
$lte
selects the documents where the value of the 选择字段值小于或等于(即field
is less than or equal to (i.e. <=
) the specified value
.<=
)指定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:考虑下面的例子:
This query will select all documents in the 此查询将选择inventory
collection where the qty
field value is less than or equal to 20
.inventory
集合中qty
字段值小于等于20
的所有单据。
Consider the following example which uses the 考虑下面的示例,该示例使用$lt
operator with a field from an embedded document:$lt
运算符和来自嵌入文档的字段:
This 此update()
operation will set the price
field value in the documents that contain the embedded document carrier
whose fee
field value is less than or equal to 5
.update()
操作将在包含fee
字段值小于或等于5
的嵌入式文档carrier
的文档中设置price
字段值。