O
OOR
文档
OOR
文档
简介
Getting Started
安装
快速开始
Query Flow
Core Concepts
Suffix
Schema
Condition Tree
Adapters
SQLite
PostgreSQL / MySQL
Elasticsearch
Integrations
Drizzle Integration
ES Client

#Suffix

oor 的查询输入是 suffix 风格。

TypeScript
{
  status: 'active',
  nameLike: 'oor',
  idIn: [1, 2, 3],
  ageMin: 18,
  createdAtDay: '2026-04-08',
  deletedAtIsNull: true
}

#常用写法

写法含义
statusEqual
statusNotNot
nameLike%text%
nameStartWithtext%
nameEndWith%text
idInIN (...)
idNotInNOT IN (...)
ageMin>=
ageMax<=
scoreMore>
scoreLess<
createdAtBetweenBETWEEN x AND y
createdAtDay当天时间范围
createdAtMonth当月时间范围
createdAtYear当年时间范围
createdAtDayStart>= 当天开始
createdAtDayEnd<= 当天结束
deletedAtIsNullIS NULL
deletedAtNotNullIS 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 模式

#下一步

  • Query Flow
  • Schema
  • Condition Tree
  • 常用写法
  • parse
  • 规则
  • 下一步