#Suffix
oor 的查询输入是 suffix 风格。
TypeScript
{
status: 'active',
nameLike: 'oor',
idIn: [1, 2, 3],
ageMin: 18,
createdAtDay: '2026-04-08',
deletedAtIsNull: true
}
#常用写法
| 写法 | 含义 |
|---|---|
status | Equal |
statusNot | Not |
nameLike | %text% |
nameStartWith | text% |
nameEndWith | %text |
idIn | IN (...) |
idNotIn | NOT IN (...) |
ageMin | >= |
ageMax | <= |
scoreMore | > |
scoreLess | < |
createdAtBetween | BETWEEN x AND y |
createdAtDay | 当天时间范围 |
createdAtMonth | 当月时间范围 |
createdAtYear | 当年时间范围 |
createdAtDayStart | >= 当天开始 |
createdAtDayEnd | <= 当天结束 |
deletedAtIsNull | IS NULL |
deletedAtNotNull | IS NOT NULL |
#parse
TypeScript
import { parse } from 'oor'
const rules = parse({
idIn: '1, 2, , 3',
nameStartWith: 'oo',
createdAtDay: '2026-04-08'
})
输出会类似:
TypeScript
[
{ field: 'id', op: 'In', value: ['1', '2', '3'], suffix: 'In' },
{ field: 'name', op: 'StartWith', value: 'oo', suffix: 'StartWith' },
{ field: 'createdAt', op: 'Between', value: [Date, Date], suffix: 'Day' }
]
#规则
In/NotIn支持数组或逗号字符串- 空项会被清掉
Day/Month/Year会展开成时间范围_start、_count、page、size、sort、order这类保留字段会被忽略- 字段是否允许某个 suffix,应继续交给
schema或strict模式