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

Like (2)
oinone's avataroinone
Previous 2023年6月20日 pm4:07
Next 2023年11月2日 pm1:58

相关推荐

  • 「前端」 获取当前用户信息以及语言

    概述 TopBarService 是用于管理用户信息和多语言配置的工具类,提供以下核心功能: 用户信息查询(含缓存机制) 当前语言状态获取 可用语言列表查询 语言切换操作 快速开始 // 基础使用示例 import { TopBarService } from '@kunlun/dependencies'; // 获取用户信息(自动缓存) const userInfo = await TopBarService.getUserInfo(); // 获取当前语言配置 const currentLang = await TopBarService.getCurrentLang(); // 查询支持的语言列表 const languages = await TopBarService.queryLanguageList(); // 激活指定语言 await TopBarService.activeLang('zh_CN'); API 详解 方法功能说明 方法名称 描述 参数 返回值 ​getUserInfo 获取当前用户信息(自动缓存) 无 用户信息对象 ​queryUserInfo 强制获取最新用户信息 无 最新用户信息对象 ​getCurrentLang 获取当前激活的语言配置 无 语言配置对象 / undefined ​queryLanguageList 获取所有可用语言列表 无 语言列表数组 ​activeLang 激活指定语言 语言 ID (string) 更新后的语言配置对象

    2025年3月21日
    1.8K00
  • 前端自定义组件之多页面步骤条

    本文将讲解如何通过自定义,实现多页面的步骤条组件。其中每个步骤的元素里都对应界面设计器的一个页面。以下是代码实现和原理分析。 代码实现 NextStepWidget 多页面步骤条 ts 组件 import { CallChaining, createRuntimeContextByView, customMutation, customQuery, RuntimeView, SPI, ViewCache, Widget, DefaultTabsWidget, BasePackWidget } from '@oinone/kunlun-dependencies'; import { isEmpty } from 'lodash-es'; import { MyMetadataViewWidget } from './MyMetadataViewWidget'; import NextStep from './NextStep.vue'; import { IStepConfig, StepDirection } from './type'; @SPI.ClassFactory(BasePackWidget.Token({ widget: 'NextStep' })) export class NextStepWidget extends DefaultTabsWidget { public initialize(props) { this.titles = props.template?.widgets?.map((item) => item.title) || []; props.template && (props.template.widgets = []); super.initialize(props); this.setComponent(NextStep); return this; } @Widget.Reactive() public get invisible() { return false; } // 配置的每一步名称 @Widget.Reactive() public titles = []; // region 上一步下一步配置 // 步骤配置,切换的顺序就是数组的顺序,模型没有限制 @Widget.Reactive() public get stepJsonConfig() { let data = JSON.parse( this.getDsl().stepJsonConfig || '[{"model":"resource.ResourceCountry","viewName":"国家form"},{"model":"resource.ResourceProvince","viewName":"省form"},{"model":"resource.ResourceCity","viewName":"市form"}]' ); return data as IStepConfig[]; } // 切换上一步下一步 @Widget.Method() public async onStepChange(stepDirection: StepDirection) { // 没有激活的,说明是初始化,取第一步 if (!this.activeStepKey) { const step = this.stepJsonConfig[0]; if (step) { this.activeStepKey = `${step.model}_${step.viewName}`; await this.initStepView(step); } return; } // 获取当前步骤的索引 if (this.currentActiveKeyIndex > -1) { await this.onSave(); // 获取下一步索引 const nextStepIndex = stepDirection === StepDirection.NEXT ? this.currentActiveKeyIndex + 1 : this.currentActiveKeyIndex – 1; // 在索引范围内,则渲染视图 if (nextStepIndex >= 0 && nextStepIndex < this.stepJsonConfig.length) { const nextStep = this.stepJsonConfig[nextStepIndex];…

    2025年7月21日
    92700
  • oio-button 按钮

    主按钮:用于主行动点,一个操作区域只能有一个主按钮。 默认按钮:用于没有主次之分的一组行动点。 虚线按钮:常用于添加操作。 文本按钮:用于最次级的行动点。 链接按钮:一般用于链接,即导航至某位置。 以及四种状态属性与上面配合使用。 危险:删除/移动/修改权限等危险操作,一般需要二次确认。 禁用:行动点不可用的时候,一般需要文案解释。 加载中:用于异步操作等待反馈的时候,也可以避免多次提交。 API 按钮的属性说明如下: 属性 说明 类型 默认值 版本 block 将按钮宽度调整为其父宽度的选项 boolean false disabled 按钮失效状态 boolean false icon 设置按钮的图标类型 v-slot – loading 设置按钮载入状态 boolean | { delay: number } false type 设置按钮类型 primary | ghost | dashed | link | text | default default 事件 事件名称 说明 回调参数 版本 click 点击按钮时的回调 (event) => void 支持原生 button 的其他所有属性。

    2023年12月18日
    88500
  • 表格字段配置Switch开关

    在业务开发中,我们经常会遇到表格中有个Switch开关组件: 那么如何通过界面设计器配置这个组件呢,下面让我们一起来学习下吧。 设计布尔类型的组件 1: 首先在界面设计器的组件区域添加一个组件。 2: 我们给这个组件添加一个元件,元件的配置必须跟下面的一致 3: 给元件添加属性配置 拖拽一个单行文本字段, 字段编码必须是truthyAction,代表的是该字段为true的时候要执行的动作 再拖拽一个单行文本字段, 字段编码必须是falsyAction,代表的是该字段为false的时候要执行的动作 4: 发布元件,然后再去对应的界面设计器页面,将对应的字段切换成刚刚设计的组件 5: 发布界面设计器,染红我们可以在运行时的页面看到效果 当switch切换的时候,会执行对应的action

    2023年11月21日
    2.5K00
  • oio-switch 开关

    API 参数 说明 类型 默认值 版本 autofocus 组件自动获取焦点 boolean false checked(v-model: checked ) 指定当前是否选中 checkedValue | unCheckedValue false checkedChildren 选中时的内容 slot checkedValue 选中时的值 boolean | string | number true disabled 是否禁用 boolean false loading 加载中的开关 boolean false unCheckedChildren 非选中时的内容 slot unCheckedValue 非选中时的值 boolean | string | number false 事件 事件名称 说明 回调参数 change 变化时回调函数 Function(checked: boolean | string | number, event: Event)

    2023年12月18日
    1.5K00

Leave a Reply

Please Login to Comment