import { BiFunction, Predicate, Supplier } from '@es-tool/core'; import { Query } from 'database-ql/dist/commonjs/query'; import { Db } from 'laf-client-sdk'; import { OrderBy } from './type/OrderBy'; /** * QueryChain 基础查询链 * 不对外开放 * @author LL * @date 2022-02-12 上午 10:36 * @param E 当前操作的表模型 类型 **/ export declare class QueryChain { /** * 数据库引用 * @type {} * @private */ protected readonly database: Db; /** * 查询条件缓存: where * @type {Record} * @private */ protected tempQuery: Record; protected whereCache: Record; /** * 显示隐藏列缓存 * @type {Record} K: 列名, E[C]: true 显示, false 隐藏 * @private */ protected tempField: Record; /** * 排序缓存 * @type {Record} * @private */ protected tempOrder: Record; protected orFlag: boolean; protected orQuery: Record[]; constructor(database: Db); /** * 部分兼容原 where 参数
* 这里传入的参数会和构造参数合并, 同名属性以 where 优先
* 注意: 使用 {@link #orAll()} 会导致此参数无效
* 和楼下 {@link #whereCmd} 不兼容 会按执行顺序覆盖 *@param where * @returns {QueryChainWrapper} */ where(where: Partial>): this; /** * 部分兼容原 where 参数, 提供 DB 对象引用 方便使用 db.command
* 这里传入的参数会和构造参数合并, 同名属性以 where 优先
* 注意: 使用 {@link #orAll()} 会导致此参数无效
* 和楼上 {@link #where} 不兼容 会按执行顺序覆盖 *@param action */ whereCmd(action: BiFunction>, Db, Partial>>): this; /** * 相等 */ eq(column: C, value: E[C]): this; eqIf(predicate: Predicate, column: C, value?: E[C]): this; eqNotNull(column: C, value?: E[C]): this; eqNotEmpty(column: C, value?: string): this; /** * 不等 */ neq(column: C, value: E[C]): this; neqIf(predicate: Predicate, column: C, value?: E[C]): this; neqNotNull(column: C, value?: E[C]): this; neqNotEmpty(column: C, value?: string): this; /** * 小于 */ lt(column: C, value: E[C]): this; ltIf(predicate: Predicate, column: C, value?: E[C]): this; /** * 小于等于 */ lte(column: C, value: E[C]): this; lteIf(predicate: Predicate, column: C, value?: E[C]): this; /** * 大于 */ gt(column: C, value: E[C]): this; gtIf(predicate: Predicate, column: C, value?: E[C]): this; /** * 大于等于 */ gte(column: C, value: E[C]): this; gteIf(predicate: Predicate, column: C, value?: E[C]): this; /** * IN */ in(column: C, value: E[C][]): this; inIf(predicate: Predicate, column: C, value?: E[C][] | E[C]): this; inNotEmpty(column: C, value?: E[C][] | E[C]): this; /** * Not In */ notIn(column: C, value: E[C][]): this; notInIf(predicate: Predicate | E[C] | undefined>, column: C, value?: Array | E[C]): this; notInNotEmpty(column: C, value: Array | E[C]): this; /** * 区间 (start, end) *@param column 列名 *@param start 开始 不含 *@param end 结束 不含 * @return {this} 返回自身 */ between(column: C, start: E[C], end: E[C]): this; /** * 反区间 相当于 (start, end) 的反集 *@param column 列名 *@param start 开始 不含 *@param end 结束 不含 * @return {this} 返回自身 */ notBetween(column: C, start: E[C], end: E[C]): this; /** * 区间 [start, end] *@param column 列名 *@param start 开始 包含 *@param end 结束 包含 * @return {this} 返回自身 */ betweenEqual(column: C, start: E[C], end: E[C]): this; /** * 反区间 [start, end] *@param column 列名 *@param start 开始 包含 *@param end 结束 包含 * @return {this} 返回自身 */ notBetweenEqual(column: C, start: E[C], end: E[C]): this; /** * 模糊匹配 相当于: {@code .*value.*} *@param column 列名 *@param value 关键字 * @return {this} 返回自身 */ like(column: C, value: string): this; /** * 条件模糊匹配 相当于: {@code .*value.*} *@param predicate 条件谓词, 接收输入值 value 返回 boolean *@param column 列名 *@param value 关键字 * @return {this} 返回自身 */ likeIf(predicate: Predicate, column: C, value?: string): this; /** * 预设条件模糊匹配, 只有 value 不是空字符串时候才会执行 *@param column 列名 *@param value 关键字 * @return {this} 返回自身 */ likeNotEmpty(column: C, value?: string): this; /** * 左 Like 相当于: {@code .*value} *@param column 列名 *@param value 关键字 * @return {this} 返回自身 */ leftLike(column: C, value: string): this; /** * 条件 左 like 相当于: {@code .*value} *@param predicate 谓词, 输入 value 输出 boolean; 输出为 true 才会添加 letKike条件 *@param column 列名 *@param value 关键字 * @return {this} 返回自身 */ leftLikeIf(predicate: Predicate, column: C, value: string): this; /** * 右 like 相当于 {@code value.*} *@param column 列名 *@param value 关键字 * @return {this} 返回自身 */ rightLike(column: C, value: string): this; /** * 条件右like 相当于 {@code value.*} *@param predicate 谓词, 输入value ,输出 boolean; 返回 true 才会添加 rightLike 条件 *@param column 列名 *@param value 关键字 * @return {this} 返回自身 */ rightLikeIf(predicate: Predicate, column: C, value: string): this; /** * 指定查询列
* 对于 mongo 无论如何都会返回 _id
* 对于关联查询列, 如果被隐藏, 结果未定义
* 和楼下 {@link #hide} 不兼容 不能同时使用 *@param column 列名 * @return {this} 返回自身 */ show(...column: C[]): this; /** * 指定隐藏列
* 可以指定 _id 隐藏ID响应
* 对于关联查询列, 如果被隐藏, 结果未定义
* 和楼上 {@link #show} 不兼容 不能同时使用 *@param column 列名 * @return {this} 返回自身 */ hide(...column: C[]): this; /** * 指定升序 *@param column 列名可变参数列表 * @return {this} 返回自身 */ orderByAsc(...column: C[]): this; /** * 指定降序 *@param column 列名可变参数列表 * @return {this} 返回自身 */ orderByDesc(...column: C[]): this; /** * 动态指定排序 *@param column 列名 *@param supplier 升序/降序枚举提供者 {@link OrderBy} * @return {this} 返回自身 */ orderBy(column: C, supplier: Supplier): this; /** * 跨列 or * TODO: 未定义 */ orAll(): this; /** * 内部: 获取where的参数 * @return {Record} * @private */ protected getWhereArg(): Record; /** * 有限 的实现, 子类需要有选择的覆盖默认实现 * @param connection * @return {any} * @protected */ protected setField(connection: Query): Query; protected setOrder(connection: Query): Query; } //# sourceMappingURL=QueryChain.d.ts.map