UNPKG

@sqb/builder

Version:

Extensible multi-dialect SQL query builder written with TypeScript

132 lines (131 loc) 4.19 kB
import { WrapOps } from './sql-objects/operators/logical-operator.js'; import { OpAnd } from './sql-objects/operators/op-and.js'; import { OpBetween } from './sql-objects/operators/op-between.js'; import { OpEq } from './sql-objects/operators/op-eq.js'; import { OpExists } from './sql-objects/operators/op-exists.js'; import { OpGt } from './sql-objects/operators/op-gt.js'; import { OpGte } from './sql-objects/operators/op-gte.js'; import { OpILike } from './sql-objects/operators/op-ilike.js'; import { OpIn } from './sql-objects/operators/op-in.js'; import { OpIs } from './sql-objects/operators/op-is.js'; import { OpIsNot } from './sql-objects/operators/op-is-not.js'; import { OpLike } from './sql-objects/operators/op-like.js'; import { OpLt } from './sql-objects/operators/op-lt.js'; import { OpLte } from './sql-objects/operators/op-lte.js'; import { OpNe } from './sql-objects/operators/op-ne.js'; import { OpNot } from './sql-objects/operators/op-not.js'; import { OpNotBetween } from './sql-objects/operators/op-not-between.js'; import { OpNotExists } from './sql-objects/operators/op-not-exists.js'; import { OpNotILike } from './sql-objects/operators/op-not-ilike.js'; import { OpNotIn } from './sql-objects/operators/op-not-in.js'; import { OpNotLike } from './sql-objects/operators/op-not-like.js'; import { OpOr } from './sql-objects/operators/op-or.js'; function And(...args) { return new OpAnd(...args); } function Or(...args) { return new OpOr(...args); } function Eq(expression, value) { return new OpEq(expression, value); } function Ne(expression, value) { return new OpNe(expression, value); } function Gt(expression, value) { return new OpGt(expression, value); } function Gte(expression, value) { return new OpGte(expression, value); } function Lt(expression, value) { return new OpLt(expression, value); } function Lte(expression, value) { return new OpLte(expression, value); } function Between(expression, value1, value2) { const values = Array.isArray(value1) ? value1 : [value1, value2]; return new OpBetween(expression, values); } function NotBetween(expression, value1, value2) { const values = Array.isArray(value1) ? value1 : [value1, value2]; return new OpNotBetween(expression, values); } function In(expression, value) { return new OpIn(expression, value); } function NotIn(expression, value) { return new OpNotIn(expression, value); } function Like(expression, value) { return new OpLike(expression, value); } function NotLike(expression, value) { return new OpNotLike(expression, value); } function Ilike(expression, value) { return new OpILike(expression, value); } function NotILike(expression, value) { return new OpNotILike(expression, value); } function Is(expression, value) { return new OpIs(expression, value); } function IsNot(expression, value) { return new OpIsNot(expression, value); } function Exists(expression) { return new OpExists(expression); } function NotExists(expression) { return new OpNotExists(expression); } function Not(expression) { return new OpNot(expression); } const op = { and: And, or: Or, eq: Eq, '=': Eq, ne: Ne, '!=': Ne, gt: Gt, '>': Gt, gte: Gte, '>=': Gte, lt: Lt, '<': Lt, lte: Lte, '<=': Lte, between: Between, btw: Between, notBetween: NotBetween, nbtw: NotBetween, '!between': NotBetween, '!btw': NotBetween, in: In, notIn: NotIn, nin: NotIn, '!in': NotIn, like: Like, not: Not, notLike: NotLike, nlike: NotLike, '!like': NotLike, ilike: Ilike, notILike: NotILike, nilike: NotILike, '!ilike': NotILike, is: Is, isNot: IsNot, '!is': IsNot, exists: Exists, notExists: NotExists, '!exists': NotExists, }; Object.assign(WrapOps, op); export { op }; export { And, Between, Eq, Eq as Equal, Exists, Gte as GreaterAnEqualTo, Gt as GreaterThan, Gt, Gte, Ilike, In, Is, IsNot, Like, Lte as LowerAndEqualTo, Lt as LowerThan, Lt, Lte, Ne, NotILike as Nilike, NotIn as Nin, NotLike as NLike, Not, NotBetween, Ne as NotEqual, NotExists, NotILike, NotIn, NotLike, Or, };