Database Manual / Reference / Query Language / Query Predicates

Comparison Query Predicate Operators比较查询谓词运算符

Comparison operators filter data based on value comparisons such as less than and greater than.比较运算符根据值比较(如小于和大于)筛选数据。

For comparison of different BSON type values, see the specified BSON comparison order.有关不同BSON类型值的比较,请参阅指定的BSON比较顺序

Operator运算符Description描述
$eqMatches values that are equal to a specified value.匹配等于指定值的值。
$gtMatches values that are greater than a specified value.匹配大于指定值的值。
$gteMatches values that are greater than or equal to a specified value.匹配大于或等于指定值的值。
$inMatches any of the values specified in an array.匹配数组中指定的任何值。
$ltMatches values that are less than a specified value.匹配小于指定值的值。
$lteMatches values that are less than or equal to a specified value.匹配小于或等于指定值的值。
$neMatches all values that are not equal to a specified value.匹配所有不等于指定值的值。
$ninMatches if the value is not equal to any of a given list of values.如果该值不等于给定值列表中的任何一个,则匹配。

Compatibility兼容性

You can use comparison operators for deployments hosted in the following environments:您可以对以下环境中托管的部署使用比较运算符:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务
  • MongoDB Enterprise: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本
  • MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本