oinone的rsql与传统sql语法对照表

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低代码应用平台体验

(1)
oinone的头像oinone
上一篇 2023年6月20日 下午4:07
下一篇 2023年11月2日 下午1:58

相关推荐

  • 如何自定义表格字段?        前端

    如何自定义表格字段?

    4.x版本开始,表格字段的渲染做了优化,同时自定义的vue文件的入口也换了新写法,普通组件的通过this.setComponent自定义vue组件,由于表格内字段同时还会有编辑态,所以入口改到了renderDefaultSlot方法内,示例代码如下 import { SPI, ViewType, BaseFieldWidget, Widget, TableN…

    2023年11月6日
    00
  • OioProvider详解        前端

    OioProvider详解

    OioProvider OioProvider是平台的初始化入口。 示例入口 main.ts import { VueOioProvider } from '@kunlun/dependencies'; VueOioProvider(); 网络请求/响应配置 http 平台统一使用apollo作为统一的http请求发起服务,并使用Grap…

    2023年11月6日
    00
  • 表格主题配置(v4)        前端

    表格主题配置(v4)

    TableThemeConfig /** * 表格主题配置 */ export interface TableThemeConfig { border: boolean | string; stripe: boolean; isCurrent: boolean; isHover: boolean; /** * 表格列主题配置 */ column: Parti…

    2023年11月1日
    00
  • 表格主题配置(v4)        前端

    表格主题配置(v4)

    TableThemeConfig /** * 表格主题配置 */ export interface TableThemeConfig { border: boolean | string; stripe: boolean; isCurrent: boolean; isHover: boolean; /** * 表格列主题配置 */ column: Parti…

    2023年11月6日
    00
  • 文件上传组件前端校验超128长度大小,不清楚怎么配置        前端

    文件上传组件前端校验超128长度大小,不清楚怎么配置

    原因是拼上后端返回的文件全路径后超出了字段的存储长度,后端通过注解@Field.String(size=1024)修改字段的存储长度后重新运行一遍服务。

    2023年11月1日
    00

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注