文档服务 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”表达式中连接过滤器 |
有关如何使用各种 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()$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
否定嵌套条件。
$not 可以用作:
- 一个逻辑运算符(例如在
filters: { $not: { // conditions... }}中) - 属性操作符(例如在
filters: { attribute-name: $not: { ... } }中)。
$and、$or 和 $not 操作符可以嵌套在另一个 $and、$or 或 $not 操作符中。