rsql | sql | 描述 |
---|---|---|
field01 == "name" | field01 = "name" | 等于 |
field01 != "name" | field01 != "name" | 不等于 |
field01 =gt= 1 | field01 > 1 | 大于 |
field01 =ge= 1 | field01 >= 1 | 大于等于 |
field01 =lt= 1 | field01 < 1 | 小于 |
field01 =le= 1 | field01 <= 1 | 小于等于 |
field01 =isnull=true | field01 is null | 字段为null |
field01 =notnull= 1 | field01 is not null | 字段不为null |
field01 =in= ("foo") | field01 in ("foo") | 多条件 |
field01 =out= ("foo") | field01 not in ("foo") | 不在多条件中 |
field01 =cole= field02 | field01 = field02 | 字段作为查询参数 |
field01 =colnt= field02 | field01 != field02 | 字段作为查询参数 |
field01 =like="foo" | field01 like "%foo%" | 全模糊匹配,rsql语法中无需拼接通配符”%“ |
field01 =starts="foo" | field01 like "foo%" | 前缀模糊匹配,rsql语法中无需拼接通配符”%“ |
field01 =ends="foo" | field01 like “%foo" | 后缀模糊匹配,rsql语法中无需拼接通配符”%“ |
field01 =notlike="foo" | field01 not like "%foo%" | 全模糊不匹配,rsql语法中无需拼接通配符”%“ |
field01 =notstarts="foo" | field01 not like "foo%" | 前缀模糊不匹配,rsql语法中无需拼接通配符”%“ |
field01 =notends="foo" | field01 not like “%foo" | 后缀模糊不匹配,rsql语法中无需拼接通配符”%“ |
field01 =has=(ENUM_NAME1, ENUM_NAME2) | 有多值枚举中的几个值 | |
field01 =hasnt=(ENUM_NAME1,ENUM_NAME2) | 没有多值枚举中的几个值 | |
field01 =bit=ENUM_NAME1 | 有二进制枚举中的单个值 | |
field01 =notbit=ENUM_NAME1 | 没有二进制枚举中的单个值 | |
前端代码中使用工具类拼接rsql
该工具类在oinone的前端基础框架中提供
import { Condition } from '@kunlun/dependencies'; const rsqlCondition = new Condition('field01').equal('foo') .and(new Condition('field02').in(['bar'])) .and(new Condition('field03').notIn(['foo'])) .or(new Condition('field04').greaterThanOrEuqalTo(12)) .or(new Condition('field05').like('foo')) .or(new Condition('field06').notStarts('bar')) .or(new Condition('field07').isNull()) .or(new Condition('field08').notNull()) .and(new Condition('field09').bitEqual('BIT_ENUM_1')) .and(new Condition('field10').bitNotEqual('BIT_ENUM_2')) .and(new Condition('field11').has('ENUM_NAME_1')) .and(new Condition('field12').hasNot(['ENUM_NAME_2', 'ENUM_NAME_3'])); const rsqlStr = rsqlCondition.toString(); console.log('rsqlCondition', rsqlStr);
// (((((((((((field01=='foo') and (field02=in=(bar))) and (field03=out=(foo))) or (field04=ge=12)) or (field05=like='foo')) or (field06=notstarts='bar')) or (field07=isnull=true)) or (field08=notnull=true)) and (field09=bit=BIT_ENUM_1)) and (field10=notbit=BIT_ENUM_2)) and (field11=has=(ENUM_NAME_1))) and (field12=hasnt=(ENUM_NAME_2,ENUM_NAME_3))
上面的执行结果中额外加了括号,等价于如下rsql语句
field01=='foo' and field02=in=(bar) and field03=out=(foo) or field04=ge=12 or field05=like='foo' or field06=notstarts='bar' or field07=isnull=true or field08=notnull=true and field09=bit=BIT_ENUM_1 and field10=notbit=BIT_ENUM_2 and field11=has=(ENUM_NAME_1) and field12=hasnt=(ENUM_NAME_2,ENUM_NAME_3)
Oinone社区 作者:oinone原创文章,如若转载,请注明出处:https://doc.oinone.top/frontend/20.html
访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验