Skip to main content

文档服务 API:筛选器

🌐 Document Service API: Filters

Page summary:

文档服务 API 提供属性操作符($eq$lt$contains 等)和逻辑操作符($and$or$not),用于筛选查询结果,并支持区分大小写和不区分大小写的匹配。

🌐 The Document Service API provides attribute operators ($eq, $lt, $contains, etc.) and logical operators ($and, $or, $not) to filter query results with support for case-sensitive and case-insensitive matching.

文档服务 API 提供筛选结果的功能。

🌐 The Document Service API offers the ability to filter results.

可以使用以下运算符:

🌐 The following operators are available:

运算符描述
$eq相等
$eqi相等(不区分大小写)
$ne不相等
$nei不等于(不区分大小写)
$lt少于
$lte小于或等于
$gt大于
$gte大于或等于
$in包含在数组中
$notIn不包含在数组中
$contains包含
$notContains不包含
$containsi包含(不区分大小写)
$notContainsi不包含(不区分大小写)
$null为空
$notNull不为空
$between介于
$startsWith以...开始
$startsWithi以…开头(不区分大小写)
$endsWith以...结尾
$endsWithi以…结尾(不区分大小写)
$or将过滤器组合成“或”表达式
$and将过滤器组合成“与”表达式
$not在“not”表达式中连接过滤器
Deep filtering with the various APIs

有关如何使用各种 API 进行深度过滤的示例,请参阅 this blog article

属性运算符

🌐 Attribute operators


strapi.documents().findMany()

$not

否定嵌套条件。

strapi.documents().findMany()

$eq

属性等于输入值。

strapi.documents().findMany()

$eqi

属性等于输入值(不区分大小写)。

strapi.documents().findMany()

$ne

属性不等于输入值。

strapi.documents().findMany()

$nei

属性不等于输入值(不区分大小写)。

strapi.documents().findMany()

$in

属性包含在输入列表中。

strapi.documents().findMany()

$notIn

输入列表中不包含属性。

strapi.documents().findMany()

$lt

属性小于输入值。

strapi.documents().findMany()

$lte

属性小于或等于输入值。

strapi.documents().findMany()

$gt

属性大于输入值。

strapi.documents().findMany()

$gte

属性大于或等于输入值。

strapi.documents().findMany()

$between

Attribute is between the 2 input values, boundaries included (e.g., $between[1, 3] will also return 1 and 3).

strapi.documents().findMany()

$contains

属性包含输入值(区分大小写)。

strapi.documents().findMany()

$notContains

属性不包含输入值(区分大小写)。

strapi.documents().findMany()

$containsi

$containsi is not case-sensitive, while $contains is.

strapi.documents().findMany()

$notContainsi

$notContainsi is not case-sensitive, while $notContains is.

strapi.documents().findMany()

$startsWith

Attribute starts with input value (case-sensitive).

strapi.documents().findMany()

$startsWithi

Attribute starts with input value (case-insensitive).

strapi.documents().findMany()

$endsWith

Attribute ends with input value (case-sensitive).

strapi.documents().findMany()

$endsWithi

Attribute ends with input value (case-insensitive).

strapi.documents().findMany()

$null

Attribute is null.

strapi.documents().findMany()

$notNull

Attribute is not null.

逻辑运算符

🌐 Logical operators

strapi.documents().findMany()

$and

All nested conditions must be true.

strapi.documents().findMany()

$or

One or many nested conditions must be true.

strapi.documents().findMany()

$not

否定嵌套条件。

Note

$not 可以用作:

  • 一个逻辑运算符(例如在 filters: { $not: { // conditions... }} 中)
  • 属性操作符(例如在 filters: { attribute-name: $not: { ... } } 中)。
Tip

$and$or$not 操作符可以嵌套在另一个 $and$or$not 操作符中。