文档服务 API:过滤器
¥Document Service API: Filters
文档服务 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 | 连接 "or" 表达式中的过滤器 |
$and | 连接 "and" 表达式中的过滤器 |
$not | 连接 "not" 表达式中的过滤器 |
使用各种 API 进行深度过滤
有关如何使用各种 API 进行深度过滤的示例,请参阅 这篇博客文章。
¥For examples of how to deep filter with the various APIs, please refer to this blog article.
属性运算符
¥Attribute operators
$not
否定嵌套条件。
¥Negates the nested condition(s).
示例
¥Example
const entries = await strapi.documents('api::article.article').findMany({
filters: {
title: {
$not: {
$contains: 'Hello World',
},
},
},
});
$eq
属性等于输入值。
¥Attribute equals input value.
示例
¥Example
const entries = await strapi.documents('api::article.article').findMany({
filters: {
title: {
$eq: 'Hello World',
},
},
});
$eq
可以省略:
¥$eq
can be omitted:
const entries = await strapi.documents('api::article.article').findMany({
filters: {
title: 'Hello World',
},
});
$eqi
属性等于输入值(不区分大小写)。
¥Attribute equals input value (case-insensitive).