Initial commit
This commit is contained in:
223
node_modules/drizzle-orm/sql/expressions/conditions.cjs
generated
vendored
Normal file
223
node_modules/drizzle-orm/sql/expressions/conditions.cjs
generated
vendored
Normal file
@ -0,0 +1,223 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var conditions_exports = {};
|
||||
__export(conditions_exports, {
|
||||
and: () => and,
|
||||
arrayContained: () => arrayContained,
|
||||
arrayContains: () => arrayContains,
|
||||
arrayOverlaps: () => arrayOverlaps,
|
||||
between: () => between,
|
||||
bindIfParam: () => bindIfParam,
|
||||
eq: () => eq,
|
||||
exists: () => exists,
|
||||
gt: () => gt,
|
||||
gte: () => gte,
|
||||
ilike: () => ilike,
|
||||
inArray: () => inArray,
|
||||
isNotNull: () => isNotNull,
|
||||
isNull: () => isNull,
|
||||
like: () => like,
|
||||
lt: () => lt,
|
||||
lte: () => lte,
|
||||
ne: () => ne,
|
||||
not: () => not,
|
||||
notBetween: () => notBetween,
|
||||
notExists: () => notExists,
|
||||
notIlike: () => notIlike,
|
||||
notInArray: () => notInArray,
|
||||
notLike: () => notLike,
|
||||
or: () => or
|
||||
});
|
||||
module.exports = __toCommonJS(conditions_exports);
|
||||
var import_column = require("../../column.cjs");
|
||||
var import_entity = require("../../entity.cjs");
|
||||
var import_table = require("../../table.cjs");
|
||||
var import_sql = require("../sql.cjs");
|
||||
function bindIfParam(value, column) {
|
||||
if ((0, import_sql.isDriverValueEncoder)(column) && !(0, import_sql.isSQLWrapper)(value) && !(0, import_entity.is)(value, import_sql.Param) && !(0, import_entity.is)(value, import_sql.Placeholder) && !(0, import_entity.is)(value, import_column.Column) && !(0, import_entity.is)(value, import_table.Table) && !(0, import_entity.is)(value, import_sql.View)) {
|
||||
return new import_sql.Param(value, column);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
const eq = (left, right) => {
|
||||
return import_sql.sql`${left} = ${bindIfParam(right, left)}`;
|
||||
};
|
||||
const ne = (left, right) => {
|
||||
return import_sql.sql`${left} <> ${bindIfParam(right, left)}`;
|
||||
};
|
||||
function and(...unfilteredConditions) {
|
||||
const conditions = unfilteredConditions.filter(
|
||||
(c) => c !== void 0
|
||||
);
|
||||
if (conditions.length === 0) {
|
||||
return void 0;
|
||||
}
|
||||
if (conditions.length === 1) {
|
||||
return new import_sql.SQL(conditions);
|
||||
}
|
||||
return new import_sql.SQL([
|
||||
new import_sql.StringChunk("("),
|
||||
import_sql.sql.join(conditions, new import_sql.StringChunk(" and ")),
|
||||
new import_sql.StringChunk(")")
|
||||
]);
|
||||
}
|
||||
function or(...unfilteredConditions) {
|
||||
const conditions = unfilteredConditions.filter(
|
||||
(c) => c !== void 0
|
||||
);
|
||||
if (conditions.length === 0) {
|
||||
return void 0;
|
||||
}
|
||||
if (conditions.length === 1) {
|
||||
return new import_sql.SQL(conditions);
|
||||
}
|
||||
return new import_sql.SQL([
|
||||
new import_sql.StringChunk("("),
|
||||
import_sql.sql.join(conditions, new import_sql.StringChunk(" or ")),
|
||||
new import_sql.StringChunk(")")
|
||||
]);
|
||||
}
|
||||
function not(condition) {
|
||||
return import_sql.sql`not ${condition}`;
|
||||
}
|
||||
const gt = (left, right) => {
|
||||
return import_sql.sql`${left} > ${bindIfParam(right, left)}`;
|
||||
};
|
||||
const gte = (left, right) => {
|
||||
return import_sql.sql`${left} >= ${bindIfParam(right, left)}`;
|
||||
};
|
||||
const lt = (left, right) => {
|
||||
return import_sql.sql`${left} < ${bindIfParam(right, left)}`;
|
||||
};
|
||||
const lte = (left, right) => {
|
||||
return import_sql.sql`${left} <= ${bindIfParam(right, left)}`;
|
||||
};
|
||||
function inArray(column, values) {
|
||||
if (Array.isArray(values)) {
|
||||
if (values.length === 0) {
|
||||
return import_sql.sql`false`;
|
||||
}
|
||||
return import_sql.sql`${column} in ${values.map((v) => bindIfParam(v, column))}`;
|
||||
}
|
||||
return import_sql.sql`${column} in ${bindIfParam(values, column)}`;
|
||||
}
|
||||
function notInArray(column, values) {
|
||||
if (Array.isArray(values)) {
|
||||
if (values.length === 0) {
|
||||
return import_sql.sql`true`;
|
||||
}
|
||||
return import_sql.sql`${column} not in ${values.map((v) => bindIfParam(v, column))}`;
|
||||
}
|
||||
return import_sql.sql`${column} not in ${bindIfParam(values, column)}`;
|
||||
}
|
||||
function isNull(value) {
|
||||
return import_sql.sql`${value} is null`;
|
||||
}
|
||||
function isNotNull(value) {
|
||||
return import_sql.sql`${value} is not null`;
|
||||
}
|
||||
function exists(subquery) {
|
||||
return import_sql.sql`exists ${subquery}`;
|
||||
}
|
||||
function notExists(subquery) {
|
||||
return import_sql.sql`not exists ${subquery}`;
|
||||
}
|
||||
function between(column, min, max) {
|
||||
return import_sql.sql`${column} between ${bindIfParam(min, column)} and ${bindIfParam(
|
||||
max,
|
||||
column
|
||||
)}`;
|
||||
}
|
||||
function notBetween(column, min, max) {
|
||||
return import_sql.sql`${column} not between ${bindIfParam(
|
||||
min,
|
||||
column
|
||||
)} and ${bindIfParam(max, column)}`;
|
||||
}
|
||||
function like(column, value) {
|
||||
return import_sql.sql`${column} like ${value}`;
|
||||
}
|
||||
function notLike(column, value) {
|
||||
return import_sql.sql`${column} not like ${value}`;
|
||||
}
|
||||
function ilike(column, value) {
|
||||
return import_sql.sql`${column} ilike ${value}`;
|
||||
}
|
||||
function notIlike(column, value) {
|
||||
return import_sql.sql`${column} not ilike ${value}`;
|
||||
}
|
||||
function arrayContains(column, values) {
|
||||
if (Array.isArray(values)) {
|
||||
if (values.length === 0) {
|
||||
throw new Error("arrayContains requires at least one value");
|
||||
}
|
||||
const array = import_sql.sql`${bindIfParam(values, column)}`;
|
||||
return import_sql.sql`${column} @> ${array}`;
|
||||
}
|
||||
return import_sql.sql`${column} @> ${bindIfParam(values, column)}`;
|
||||
}
|
||||
function arrayContained(column, values) {
|
||||
if (Array.isArray(values)) {
|
||||
if (values.length === 0) {
|
||||
throw new Error("arrayContained requires at least one value");
|
||||
}
|
||||
const array = import_sql.sql`${bindIfParam(values, column)}`;
|
||||
return import_sql.sql`${column} <@ ${array}`;
|
||||
}
|
||||
return import_sql.sql`${column} <@ ${bindIfParam(values, column)}`;
|
||||
}
|
||||
function arrayOverlaps(column, values) {
|
||||
if (Array.isArray(values)) {
|
||||
if (values.length === 0) {
|
||||
throw new Error("arrayOverlaps requires at least one value");
|
||||
}
|
||||
const array = import_sql.sql`${bindIfParam(values, column)}`;
|
||||
return import_sql.sql`${column} && ${array}`;
|
||||
}
|
||||
return import_sql.sql`${column} && ${bindIfParam(values, column)}`;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
and,
|
||||
arrayContained,
|
||||
arrayContains,
|
||||
arrayOverlaps,
|
||||
between,
|
||||
bindIfParam,
|
||||
eq,
|
||||
exists,
|
||||
gt,
|
||||
gte,
|
||||
ilike,
|
||||
inArray,
|
||||
isNotNull,
|
||||
isNull,
|
||||
like,
|
||||
lt,
|
||||
lte,
|
||||
ne,
|
||||
not,
|
||||
notBetween,
|
||||
notExists,
|
||||
notIlike,
|
||||
notInArray,
|
||||
notLike,
|
||||
or
|
||||
});
|
||||
//# sourceMappingURL=conditions.cjs.map
|
||||
1
node_modules/drizzle-orm/sql/expressions/conditions.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/sql/expressions/conditions.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
453
node_modules/drizzle-orm/sql/expressions/conditions.d.cts
generated
vendored
Normal file
453
node_modules/drizzle-orm/sql/expressions/conditions.d.cts
generated
vendored
Normal file
@ -0,0 +1,453 @@
|
||||
import { type AnyColumn, Column, type GetColumnData } from "../../column.cjs";
|
||||
import { Placeholder, SQL, type SQLChunk, type SQLWrapper } from "../sql.cjs";
|
||||
export declare function bindIfParam(value: unknown, column: SQLWrapper): SQLChunk;
|
||||
export interface BinaryOperator {
|
||||
<TColumn extends Column>(left: TColumn, right: GetColumnData<TColumn, 'raw'> | SQLWrapper): SQL;
|
||||
<T>(left: SQL.Aliased<T>, right: T | SQLWrapper): SQL;
|
||||
<T extends SQLWrapper>(left: Exclude<T, SQL.Aliased | Column>, right: unknown): SQL;
|
||||
}
|
||||
/**
|
||||
* Test that two values are equal.
|
||||
*
|
||||
* Remember that the SQL standard dictates that
|
||||
* two NULL values are not equal, so if you want to test
|
||||
* whether a value is null, you may want to use
|
||||
* `isNull` instead.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made by Ford
|
||||
* db.select().from(cars)
|
||||
* .where(eq(cars.make, 'Ford'))
|
||||
* ```
|
||||
*
|
||||
* @see isNull for a way to test equality to NULL.
|
||||
*/
|
||||
export declare const eq: BinaryOperator;
|
||||
/**
|
||||
* Test that two values are not equal.
|
||||
*
|
||||
* Remember that the SQL standard dictates that
|
||||
* two NULL values are not equal, so if you want to test
|
||||
* whether a value is not null, you may want to use
|
||||
* `isNotNull` instead.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars not made by Ford
|
||||
* db.select().from(cars)
|
||||
* .where(ne(cars.make, 'Ford'))
|
||||
* ```
|
||||
*
|
||||
* @see isNotNull for a way to test whether a value is not null.
|
||||
*/
|
||||
export declare const ne: BinaryOperator;
|
||||
/**
|
||||
* Combine a list of conditions with the `and` operator. Conditions
|
||||
* that are equal `undefined` are automatically ignored.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* db.select().from(cars)
|
||||
* .where(
|
||||
* and(
|
||||
* eq(cars.make, 'Volvo'),
|
||||
* eq(cars.year, 1950),
|
||||
* )
|
||||
* )
|
||||
* ```
|
||||
*/
|
||||
export declare function and(...conditions: (SQLWrapper | undefined)[]): SQL | undefined;
|
||||
/**
|
||||
* Combine a list of conditions with the `or` operator. Conditions
|
||||
* that are equal `undefined` are automatically ignored.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* db.select().from(cars)
|
||||
* .where(
|
||||
* or(
|
||||
* eq(cars.make, 'GM'),
|
||||
* eq(cars.make, 'Ford'),
|
||||
* )
|
||||
* )
|
||||
* ```
|
||||
*/
|
||||
export declare function or(...conditions: (SQLWrapper | undefined)[]): SQL | undefined;
|
||||
/**
|
||||
* Negate the meaning of an expression using the `not` keyword.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars _not_ made by GM or Ford.
|
||||
* db.select().from(cars)
|
||||
* .where(not(inArray(cars.make, ['GM', 'Ford'])))
|
||||
* ```
|
||||
*/
|
||||
export declare function not(condition: SQLWrapper): SQL;
|
||||
/**
|
||||
* Test that the first expression passed is greater than
|
||||
* the second expression.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made after 2000.
|
||||
* db.select().from(cars)
|
||||
* .where(gt(cars.year, 2000))
|
||||
* ```
|
||||
*
|
||||
* @see gte for greater-than-or-equal
|
||||
*/
|
||||
export declare const gt: BinaryOperator;
|
||||
/**
|
||||
* Test that the first expression passed is greater than
|
||||
* or equal to the second expression. Use `gt` to
|
||||
* test whether an expression is strictly greater
|
||||
* than another.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made on or after 2000.
|
||||
* db.select().from(cars)
|
||||
* .where(gte(cars.year, 2000))
|
||||
* ```
|
||||
*
|
||||
* @see gt for a strictly greater-than condition
|
||||
*/
|
||||
export declare const gte: BinaryOperator;
|
||||
/**
|
||||
* Test that the first expression passed is less than
|
||||
* the second expression.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made before 2000.
|
||||
* db.select().from(cars)
|
||||
* .where(lt(cars.year, 2000))
|
||||
* ```
|
||||
*
|
||||
* @see lte for less-than-or-equal
|
||||
*/
|
||||
export declare const lt: BinaryOperator;
|
||||
/**
|
||||
* Test that the first expression passed is less than
|
||||
* or equal to the second expression.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made before 2000.
|
||||
* db.select().from(cars)
|
||||
* .where(lte(cars.year, 2000))
|
||||
* ```
|
||||
*
|
||||
* @see lt for a strictly less-than condition
|
||||
*/
|
||||
export declare const lte: BinaryOperator;
|
||||
/**
|
||||
* Test whether the first parameter, a column or expression,
|
||||
* has a value from a list passed as the second argument.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made by Ford or GM.
|
||||
* db.select().from(cars)
|
||||
* .where(inArray(cars.make, ['Ford', 'GM']))
|
||||
* ```
|
||||
*
|
||||
* @see notInArray for the inverse of this test
|
||||
*/
|
||||
export declare function inArray<T>(column: SQL.Aliased<T>, values: (T | Placeholder)[] | SQLWrapper): SQL;
|
||||
export declare function inArray<TColumn extends Column>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder)[] | SQLWrapper): SQL;
|
||||
export declare function inArray<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, values: (unknown | Placeholder)[] | SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether the first parameter, a column or expression,
|
||||
* has a value that is not present in a list passed as the
|
||||
* second argument.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made by any company except Ford or GM.
|
||||
* db.select().from(cars)
|
||||
* .where(notInArray(cars.make, ['Ford', 'GM']))
|
||||
* ```
|
||||
*
|
||||
* @see inArray for the inverse of this test
|
||||
*/
|
||||
export declare function notInArray<T>(column: SQL.Aliased<T>, values: (T | Placeholder)[] | SQLWrapper): SQL;
|
||||
export declare function notInArray<TColumn extends Column>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder)[] | SQLWrapper): SQL;
|
||||
export declare function notInArray<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, values: (unknown | Placeholder)[] | SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether an expression is NULL. By the SQL standard,
|
||||
* NULL is neither equal nor not equal to itself, so
|
||||
* it's recommended to use `isNull` and `notIsNull` for
|
||||
* comparisons to NULL.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars that have no discontinuedAt date.
|
||||
* db.select().from(cars)
|
||||
* .where(isNull(cars.discontinuedAt))
|
||||
* ```
|
||||
*
|
||||
* @see isNotNull for the inverse of this test
|
||||
*/
|
||||
export declare function isNull(value: SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether an expression is not NULL. By the SQL standard,
|
||||
* NULL is neither equal nor not equal to itself, so
|
||||
* it's recommended to use `isNull` and `notIsNull` for
|
||||
* comparisons to NULL.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars that have been discontinued.
|
||||
* db.select().from(cars)
|
||||
* .where(isNotNull(cars.discontinuedAt))
|
||||
* ```
|
||||
*
|
||||
* @see isNull for the inverse of this test
|
||||
*/
|
||||
export declare function isNotNull(value: SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether a subquery evaluates to have any rows.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Users whose `homeCity` column has a match in a cities
|
||||
* // table.
|
||||
* db
|
||||
* .select()
|
||||
* .from(users)
|
||||
* .where(
|
||||
* exists(db.select()
|
||||
* .from(cities)
|
||||
* .where(eq(users.homeCity, cities.id))),
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @see notExists for the inverse of this test
|
||||
*/
|
||||
export declare function exists(subquery: SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether a subquery doesn't include any result
|
||||
* rows.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Users whose `homeCity` column doesn't match
|
||||
* // a row in the cities table.
|
||||
* db
|
||||
* .select()
|
||||
* .from(users)
|
||||
* .where(
|
||||
* notExists(db.select()
|
||||
* .from(cities)
|
||||
* .where(eq(users.homeCity, cities.id))),
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @see exists for the inverse of this test
|
||||
*/
|
||||
export declare function notExists(subquery: SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether an expression is between two values. This
|
||||
* is an easier way to express range tests, which would be
|
||||
* expressed mathematically as `x <= a <= y` but in SQL
|
||||
* would have to be like `a >= x AND a <= y`.
|
||||
*
|
||||
* Between is inclusive of the endpoints: if `column`
|
||||
* is equal to `min` or `max`, it will be TRUE.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made between 1990 and 2000
|
||||
* db.select().from(cars)
|
||||
* .where(between(cars.year, 1990, 2000))
|
||||
* ```
|
||||
*
|
||||
* @see notBetween for the inverse of this test
|
||||
*/
|
||||
export declare function between<T>(column: SQL.Aliased, min: T | SQLWrapper, max: T | SQLWrapper): SQL;
|
||||
export declare function between<TColumn extends AnyColumn>(column: TColumn, min: GetColumnData<TColumn, 'raw'> | SQLWrapper, max: GetColumnData<TColumn, 'raw'> | SQLWrapper): SQL;
|
||||
export declare function between<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, min: unknown, max: unknown): SQL;
|
||||
/**
|
||||
* Test whether an expression is not between two values.
|
||||
*
|
||||
* This, like `between`, includes its endpoints, so if
|
||||
* the `column` is equal to `min` or `max`, in this case
|
||||
* it will evaluate to FALSE.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Exclude cars made in the 1970s
|
||||
* db.select().from(cars)
|
||||
* .where(notBetween(cars.year, 1970, 1979))
|
||||
* ```
|
||||
*
|
||||
* @see between for the inverse of this test
|
||||
*/
|
||||
export declare function notBetween<T>(column: SQL.Aliased, min: T | SQLWrapper, max: T | SQLWrapper): SQL;
|
||||
export declare function notBetween<TColumn extends AnyColumn>(column: TColumn, min: GetColumnData<TColumn, 'raw'> | SQLWrapper, max: GetColumnData<TColumn, 'raw'> | SQLWrapper): SQL;
|
||||
export declare function notBetween<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, min: unknown, max: unknown): SQL;
|
||||
/**
|
||||
* Compare a column to a pattern, which can include `%` and `_`
|
||||
* characters to match multiple variations. Including `%`
|
||||
* in the pattern matches zero or more characters, and including
|
||||
* `_` will match a single character.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select all cars with 'Turbo' in their names.
|
||||
* db.select().from(cars)
|
||||
* .where(like(cars.name, '%Turbo%'))
|
||||
* ```
|
||||
*
|
||||
* @see ilike for a case-insensitive version of this condition
|
||||
*/
|
||||
export declare function like(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL;
|
||||
/**
|
||||
* The inverse of like - this tests that a given column
|
||||
* does not match a pattern, which can include `%` and `_`
|
||||
* characters to match multiple variations. Including `%`
|
||||
* in the pattern matches zero or more characters, and including
|
||||
* `_` will match a single character.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select all cars that don't have "ROver" in their name.
|
||||
* db.select().from(cars)
|
||||
* .where(notLike(cars.name, '%Rover%'))
|
||||
* ```
|
||||
*
|
||||
* @see like for the inverse condition
|
||||
* @see notIlike for a case-insensitive version of this condition
|
||||
*/
|
||||
export declare function notLike(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL;
|
||||
/**
|
||||
* Case-insensitively compare a column to a pattern,
|
||||
* which can include `%` and `_`
|
||||
* characters to match multiple variations. Including `%`
|
||||
* in the pattern matches zero or more characters, and including
|
||||
* `_` will match a single character.
|
||||
*
|
||||
* Unlike like, this performs a case-insensitive comparison.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select all cars with 'Turbo' in their names.
|
||||
* db.select().from(cars)
|
||||
* .where(ilike(cars.name, '%Turbo%'))
|
||||
* ```
|
||||
*
|
||||
* @see like for a case-sensitive version of this condition
|
||||
*/
|
||||
export declare function ilike(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL;
|
||||
/**
|
||||
* The inverse of ilike - this case-insensitively tests that a given column
|
||||
* does not match a pattern, which can include `%` and `_`
|
||||
* characters to match multiple variations. Including `%`
|
||||
* in the pattern matches zero or more characters, and including
|
||||
* `_` will match a single character.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select all cars that don't have "Rover" in their name.
|
||||
* db.select().from(cars)
|
||||
* .where(notLike(cars.name, '%Rover%'))
|
||||
* ```
|
||||
*
|
||||
* @see ilike for the inverse condition
|
||||
* @see notLike for a case-sensitive version of this condition
|
||||
*/
|
||||
export declare function notIlike(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL;
|
||||
/**
|
||||
* Test that a column or expression contains all elements of
|
||||
* the list passed as the second argument.
|
||||
*
|
||||
* ## Throws
|
||||
*
|
||||
* The argument passed in the second array can't be empty:
|
||||
* if an empty is provided, this method will throw.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select posts where its tags contain "Typescript" and "ORM".
|
||||
* db.select().from(posts)
|
||||
* .where(arrayContains(posts.tags, ['Typescript', 'ORM']))
|
||||
* ```
|
||||
*
|
||||
* @see arrayContained to find if an array contains all elements of a column or expression
|
||||
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
||||
*/
|
||||
export declare function arrayContains<T>(column: SQL.Aliased<T>, values: (T | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayContains<TColumn extends Column>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayContains<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, values: (unknown | Placeholder)[] | SQLWrapper): SQL;
|
||||
/**
|
||||
* Test that the list passed as the second argument contains
|
||||
* all elements of a column or expression.
|
||||
*
|
||||
* ## Throws
|
||||
*
|
||||
* The argument passed in the second array can't be empty:
|
||||
* if an empty is provided, this method will throw.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select posts where its tags contain "Typescript", "ORM" or both,
|
||||
* // but filtering posts that have additional tags.
|
||||
* db.select().from(posts)
|
||||
* .where(arrayContained(posts.tags, ['Typescript', 'ORM']))
|
||||
* ```
|
||||
*
|
||||
* @see arrayContains to find if a column or expression contains all elements of an array
|
||||
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
||||
*/
|
||||
export declare function arrayContained<T>(column: SQL.Aliased<T>, values: (T | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayContained<TColumn extends Column>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayContained<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, values: (unknown | Placeholder)[] | SQLWrapper): SQL;
|
||||
/**
|
||||
* Test that a column or expression contains any elements of
|
||||
* the list passed as the second argument.
|
||||
*
|
||||
* ## Throws
|
||||
*
|
||||
* The argument passed in the second array can't be empty:
|
||||
* if an empty is provided, this method will throw.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select posts where its tags contain "Typescript", "ORM" or both.
|
||||
* db.select().from(posts)
|
||||
* .where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']))
|
||||
* ```
|
||||
*
|
||||
* @see arrayContains to find if a column or expression contains all elements of an array
|
||||
* @see arrayContained to find if an array contains all elements of a column or expression
|
||||
*/
|
||||
export declare function arrayOverlaps<T>(column: SQL.Aliased<T>, values: (T | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayOverlaps<TColumn extends Column>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayOverlaps<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, values: (unknown | Placeholder)[] | SQLWrapper): SQL;
|
||||
453
node_modules/drizzle-orm/sql/expressions/conditions.d.ts
generated
vendored
Normal file
453
node_modules/drizzle-orm/sql/expressions/conditions.d.ts
generated
vendored
Normal file
@ -0,0 +1,453 @@
|
||||
import { type AnyColumn, Column, type GetColumnData } from "../../column.js";
|
||||
import { Placeholder, SQL, type SQLChunk, type SQLWrapper } from "../sql.js";
|
||||
export declare function bindIfParam(value: unknown, column: SQLWrapper): SQLChunk;
|
||||
export interface BinaryOperator {
|
||||
<TColumn extends Column>(left: TColumn, right: GetColumnData<TColumn, 'raw'> | SQLWrapper): SQL;
|
||||
<T>(left: SQL.Aliased<T>, right: T | SQLWrapper): SQL;
|
||||
<T extends SQLWrapper>(left: Exclude<T, SQL.Aliased | Column>, right: unknown): SQL;
|
||||
}
|
||||
/**
|
||||
* Test that two values are equal.
|
||||
*
|
||||
* Remember that the SQL standard dictates that
|
||||
* two NULL values are not equal, so if you want to test
|
||||
* whether a value is null, you may want to use
|
||||
* `isNull` instead.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made by Ford
|
||||
* db.select().from(cars)
|
||||
* .where(eq(cars.make, 'Ford'))
|
||||
* ```
|
||||
*
|
||||
* @see isNull for a way to test equality to NULL.
|
||||
*/
|
||||
export declare const eq: BinaryOperator;
|
||||
/**
|
||||
* Test that two values are not equal.
|
||||
*
|
||||
* Remember that the SQL standard dictates that
|
||||
* two NULL values are not equal, so if you want to test
|
||||
* whether a value is not null, you may want to use
|
||||
* `isNotNull` instead.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars not made by Ford
|
||||
* db.select().from(cars)
|
||||
* .where(ne(cars.make, 'Ford'))
|
||||
* ```
|
||||
*
|
||||
* @see isNotNull for a way to test whether a value is not null.
|
||||
*/
|
||||
export declare const ne: BinaryOperator;
|
||||
/**
|
||||
* Combine a list of conditions with the `and` operator. Conditions
|
||||
* that are equal `undefined` are automatically ignored.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* db.select().from(cars)
|
||||
* .where(
|
||||
* and(
|
||||
* eq(cars.make, 'Volvo'),
|
||||
* eq(cars.year, 1950),
|
||||
* )
|
||||
* )
|
||||
* ```
|
||||
*/
|
||||
export declare function and(...conditions: (SQLWrapper | undefined)[]): SQL | undefined;
|
||||
/**
|
||||
* Combine a list of conditions with the `or` operator. Conditions
|
||||
* that are equal `undefined` are automatically ignored.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* db.select().from(cars)
|
||||
* .where(
|
||||
* or(
|
||||
* eq(cars.make, 'GM'),
|
||||
* eq(cars.make, 'Ford'),
|
||||
* )
|
||||
* )
|
||||
* ```
|
||||
*/
|
||||
export declare function or(...conditions: (SQLWrapper | undefined)[]): SQL | undefined;
|
||||
/**
|
||||
* Negate the meaning of an expression using the `not` keyword.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars _not_ made by GM or Ford.
|
||||
* db.select().from(cars)
|
||||
* .where(not(inArray(cars.make, ['GM', 'Ford'])))
|
||||
* ```
|
||||
*/
|
||||
export declare function not(condition: SQLWrapper): SQL;
|
||||
/**
|
||||
* Test that the first expression passed is greater than
|
||||
* the second expression.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made after 2000.
|
||||
* db.select().from(cars)
|
||||
* .where(gt(cars.year, 2000))
|
||||
* ```
|
||||
*
|
||||
* @see gte for greater-than-or-equal
|
||||
*/
|
||||
export declare const gt: BinaryOperator;
|
||||
/**
|
||||
* Test that the first expression passed is greater than
|
||||
* or equal to the second expression. Use `gt` to
|
||||
* test whether an expression is strictly greater
|
||||
* than another.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made on or after 2000.
|
||||
* db.select().from(cars)
|
||||
* .where(gte(cars.year, 2000))
|
||||
* ```
|
||||
*
|
||||
* @see gt for a strictly greater-than condition
|
||||
*/
|
||||
export declare const gte: BinaryOperator;
|
||||
/**
|
||||
* Test that the first expression passed is less than
|
||||
* the second expression.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made before 2000.
|
||||
* db.select().from(cars)
|
||||
* .where(lt(cars.year, 2000))
|
||||
* ```
|
||||
*
|
||||
* @see lte for less-than-or-equal
|
||||
*/
|
||||
export declare const lt: BinaryOperator;
|
||||
/**
|
||||
* Test that the first expression passed is less than
|
||||
* or equal to the second expression.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made before 2000.
|
||||
* db.select().from(cars)
|
||||
* .where(lte(cars.year, 2000))
|
||||
* ```
|
||||
*
|
||||
* @see lt for a strictly less-than condition
|
||||
*/
|
||||
export declare const lte: BinaryOperator;
|
||||
/**
|
||||
* Test whether the first parameter, a column or expression,
|
||||
* has a value from a list passed as the second argument.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made by Ford or GM.
|
||||
* db.select().from(cars)
|
||||
* .where(inArray(cars.make, ['Ford', 'GM']))
|
||||
* ```
|
||||
*
|
||||
* @see notInArray for the inverse of this test
|
||||
*/
|
||||
export declare function inArray<T>(column: SQL.Aliased<T>, values: (T | Placeholder)[] | SQLWrapper): SQL;
|
||||
export declare function inArray<TColumn extends Column>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder)[] | SQLWrapper): SQL;
|
||||
export declare function inArray<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, values: (unknown | Placeholder)[] | SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether the first parameter, a column or expression,
|
||||
* has a value that is not present in a list passed as the
|
||||
* second argument.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made by any company except Ford or GM.
|
||||
* db.select().from(cars)
|
||||
* .where(notInArray(cars.make, ['Ford', 'GM']))
|
||||
* ```
|
||||
*
|
||||
* @see inArray for the inverse of this test
|
||||
*/
|
||||
export declare function notInArray<T>(column: SQL.Aliased<T>, values: (T | Placeholder)[] | SQLWrapper): SQL;
|
||||
export declare function notInArray<TColumn extends Column>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder)[] | SQLWrapper): SQL;
|
||||
export declare function notInArray<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, values: (unknown | Placeholder)[] | SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether an expression is NULL. By the SQL standard,
|
||||
* NULL is neither equal nor not equal to itself, so
|
||||
* it's recommended to use `isNull` and `notIsNull` for
|
||||
* comparisons to NULL.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars that have no discontinuedAt date.
|
||||
* db.select().from(cars)
|
||||
* .where(isNull(cars.discontinuedAt))
|
||||
* ```
|
||||
*
|
||||
* @see isNotNull for the inverse of this test
|
||||
*/
|
||||
export declare function isNull(value: SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether an expression is not NULL. By the SQL standard,
|
||||
* NULL is neither equal nor not equal to itself, so
|
||||
* it's recommended to use `isNull` and `notIsNull` for
|
||||
* comparisons to NULL.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars that have been discontinued.
|
||||
* db.select().from(cars)
|
||||
* .where(isNotNull(cars.discontinuedAt))
|
||||
* ```
|
||||
*
|
||||
* @see isNull for the inverse of this test
|
||||
*/
|
||||
export declare function isNotNull(value: SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether a subquery evaluates to have any rows.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Users whose `homeCity` column has a match in a cities
|
||||
* // table.
|
||||
* db
|
||||
* .select()
|
||||
* .from(users)
|
||||
* .where(
|
||||
* exists(db.select()
|
||||
* .from(cities)
|
||||
* .where(eq(users.homeCity, cities.id))),
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @see notExists for the inverse of this test
|
||||
*/
|
||||
export declare function exists(subquery: SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether a subquery doesn't include any result
|
||||
* rows.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Users whose `homeCity` column doesn't match
|
||||
* // a row in the cities table.
|
||||
* db
|
||||
* .select()
|
||||
* .from(users)
|
||||
* .where(
|
||||
* notExists(db.select()
|
||||
* .from(cities)
|
||||
* .where(eq(users.homeCity, cities.id))),
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @see exists for the inverse of this test
|
||||
*/
|
||||
export declare function notExists(subquery: SQLWrapper): SQL;
|
||||
/**
|
||||
* Test whether an expression is between two values. This
|
||||
* is an easier way to express range tests, which would be
|
||||
* expressed mathematically as `x <= a <= y` but in SQL
|
||||
* would have to be like `a >= x AND a <= y`.
|
||||
*
|
||||
* Between is inclusive of the endpoints: if `column`
|
||||
* is equal to `min` or `max`, it will be TRUE.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars made between 1990 and 2000
|
||||
* db.select().from(cars)
|
||||
* .where(between(cars.year, 1990, 2000))
|
||||
* ```
|
||||
*
|
||||
* @see notBetween for the inverse of this test
|
||||
*/
|
||||
export declare function between<T>(column: SQL.Aliased, min: T | SQLWrapper, max: T | SQLWrapper): SQL;
|
||||
export declare function between<TColumn extends AnyColumn>(column: TColumn, min: GetColumnData<TColumn, 'raw'> | SQLWrapper, max: GetColumnData<TColumn, 'raw'> | SQLWrapper): SQL;
|
||||
export declare function between<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, min: unknown, max: unknown): SQL;
|
||||
/**
|
||||
* Test whether an expression is not between two values.
|
||||
*
|
||||
* This, like `between`, includes its endpoints, so if
|
||||
* the `column` is equal to `min` or `max`, in this case
|
||||
* it will evaluate to FALSE.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Exclude cars made in the 1970s
|
||||
* db.select().from(cars)
|
||||
* .where(notBetween(cars.year, 1970, 1979))
|
||||
* ```
|
||||
*
|
||||
* @see between for the inverse of this test
|
||||
*/
|
||||
export declare function notBetween<T>(column: SQL.Aliased, min: T | SQLWrapper, max: T | SQLWrapper): SQL;
|
||||
export declare function notBetween<TColumn extends AnyColumn>(column: TColumn, min: GetColumnData<TColumn, 'raw'> | SQLWrapper, max: GetColumnData<TColumn, 'raw'> | SQLWrapper): SQL;
|
||||
export declare function notBetween<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, min: unknown, max: unknown): SQL;
|
||||
/**
|
||||
* Compare a column to a pattern, which can include `%` and `_`
|
||||
* characters to match multiple variations. Including `%`
|
||||
* in the pattern matches zero or more characters, and including
|
||||
* `_` will match a single character.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select all cars with 'Turbo' in their names.
|
||||
* db.select().from(cars)
|
||||
* .where(like(cars.name, '%Turbo%'))
|
||||
* ```
|
||||
*
|
||||
* @see ilike for a case-insensitive version of this condition
|
||||
*/
|
||||
export declare function like(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL;
|
||||
/**
|
||||
* The inverse of like - this tests that a given column
|
||||
* does not match a pattern, which can include `%` and `_`
|
||||
* characters to match multiple variations. Including `%`
|
||||
* in the pattern matches zero or more characters, and including
|
||||
* `_` will match a single character.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select all cars that don't have "ROver" in their name.
|
||||
* db.select().from(cars)
|
||||
* .where(notLike(cars.name, '%Rover%'))
|
||||
* ```
|
||||
*
|
||||
* @see like for the inverse condition
|
||||
* @see notIlike for a case-insensitive version of this condition
|
||||
*/
|
||||
export declare function notLike(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL;
|
||||
/**
|
||||
* Case-insensitively compare a column to a pattern,
|
||||
* which can include `%` and `_`
|
||||
* characters to match multiple variations. Including `%`
|
||||
* in the pattern matches zero or more characters, and including
|
||||
* `_` will match a single character.
|
||||
*
|
||||
* Unlike like, this performs a case-insensitive comparison.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select all cars with 'Turbo' in their names.
|
||||
* db.select().from(cars)
|
||||
* .where(ilike(cars.name, '%Turbo%'))
|
||||
* ```
|
||||
*
|
||||
* @see like for a case-sensitive version of this condition
|
||||
*/
|
||||
export declare function ilike(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL;
|
||||
/**
|
||||
* The inverse of ilike - this case-insensitively tests that a given column
|
||||
* does not match a pattern, which can include `%` and `_`
|
||||
* characters to match multiple variations. Including `%`
|
||||
* in the pattern matches zero or more characters, and including
|
||||
* `_` will match a single character.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select all cars that don't have "Rover" in their name.
|
||||
* db.select().from(cars)
|
||||
* .where(notLike(cars.name, '%Rover%'))
|
||||
* ```
|
||||
*
|
||||
* @see ilike for the inverse condition
|
||||
* @see notLike for a case-sensitive version of this condition
|
||||
*/
|
||||
export declare function notIlike(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL;
|
||||
/**
|
||||
* Test that a column or expression contains all elements of
|
||||
* the list passed as the second argument.
|
||||
*
|
||||
* ## Throws
|
||||
*
|
||||
* The argument passed in the second array can't be empty:
|
||||
* if an empty is provided, this method will throw.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select posts where its tags contain "Typescript" and "ORM".
|
||||
* db.select().from(posts)
|
||||
* .where(arrayContains(posts.tags, ['Typescript', 'ORM']))
|
||||
* ```
|
||||
*
|
||||
* @see arrayContained to find if an array contains all elements of a column or expression
|
||||
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
||||
*/
|
||||
export declare function arrayContains<T>(column: SQL.Aliased<T>, values: (T | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayContains<TColumn extends Column>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayContains<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, values: (unknown | Placeholder)[] | SQLWrapper): SQL;
|
||||
/**
|
||||
* Test that the list passed as the second argument contains
|
||||
* all elements of a column or expression.
|
||||
*
|
||||
* ## Throws
|
||||
*
|
||||
* The argument passed in the second array can't be empty:
|
||||
* if an empty is provided, this method will throw.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select posts where its tags contain "Typescript", "ORM" or both,
|
||||
* // but filtering posts that have additional tags.
|
||||
* db.select().from(posts)
|
||||
* .where(arrayContained(posts.tags, ['Typescript', 'ORM']))
|
||||
* ```
|
||||
*
|
||||
* @see arrayContains to find if a column or expression contains all elements of an array
|
||||
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
||||
*/
|
||||
export declare function arrayContained<T>(column: SQL.Aliased<T>, values: (T | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayContained<TColumn extends Column>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayContained<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, values: (unknown | Placeholder)[] | SQLWrapper): SQL;
|
||||
/**
|
||||
* Test that a column or expression contains any elements of
|
||||
* the list passed as the second argument.
|
||||
*
|
||||
* ## Throws
|
||||
*
|
||||
* The argument passed in the second array can't be empty:
|
||||
* if an empty is provided, this method will throw.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select posts where its tags contain "Typescript", "ORM" or both.
|
||||
* db.select().from(posts)
|
||||
* .where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']))
|
||||
* ```
|
||||
*
|
||||
* @see arrayContains to find if a column or expression contains all elements of an array
|
||||
* @see arrayContained to find if an array contains all elements of a column or expression
|
||||
*/
|
||||
export declare function arrayOverlaps<T>(column: SQL.Aliased<T>, values: (T | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayOverlaps<TColumn extends Column>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder) | SQLWrapper): SQL;
|
||||
export declare function arrayOverlaps<T extends SQLWrapper>(column: Exclude<T, SQL.Aliased | Column>, values: (unknown | Placeholder)[] | SQLWrapper): SQL;
|
||||
184
node_modules/drizzle-orm/sql/expressions/conditions.js
generated
vendored
Normal file
184
node_modules/drizzle-orm/sql/expressions/conditions.js
generated
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
import { Column } from "../../column.js";
|
||||
import { is } from "../../entity.js";
|
||||
import { Table } from "../../table.js";
|
||||
import {
|
||||
isDriverValueEncoder,
|
||||
isSQLWrapper,
|
||||
Param,
|
||||
Placeholder,
|
||||
SQL,
|
||||
sql,
|
||||
StringChunk,
|
||||
View
|
||||
} from "../sql.js";
|
||||
function bindIfParam(value, column) {
|
||||
if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) {
|
||||
return new Param(value, column);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
const eq = (left, right) => {
|
||||
return sql`${left} = ${bindIfParam(right, left)}`;
|
||||
};
|
||||
const ne = (left, right) => {
|
||||
return sql`${left} <> ${bindIfParam(right, left)}`;
|
||||
};
|
||||
function and(...unfilteredConditions) {
|
||||
const conditions = unfilteredConditions.filter(
|
||||
(c) => c !== void 0
|
||||
);
|
||||
if (conditions.length === 0) {
|
||||
return void 0;
|
||||
}
|
||||
if (conditions.length === 1) {
|
||||
return new SQL(conditions);
|
||||
}
|
||||
return new SQL([
|
||||
new StringChunk("("),
|
||||
sql.join(conditions, new StringChunk(" and ")),
|
||||
new StringChunk(")")
|
||||
]);
|
||||
}
|
||||
function or(...unfilteredConditions) {
|
||||
const conditions = unfilteredConditions.filter(
|
||||
(c) => c !== void 0
|
||||
);
|
||||
if (conditions.length === 0) {
|
||||
return void 0;
|
||||
}
|
||||
if (conditions.length === 1) {
|
||||
return new SQL(conditions);
|
||||
}
|
||||
return new SQL([
|
||||
new StringChunk("("),
|
||||
sql.join(conditions, new StringChunk(" or ")),
|
||||
new StringChunk(")")
|
||||
]);
|
||||
}
|
||||
function not(condition) {
|
||||
return sql`not ${condition}`;
|
||||
}
|
||||
const gt = (left, right) => {
|
||||
return sql`${left} > ${bindIfParam(right, left)}`;
|
||||
};
|
||||
const gte = (left, right) => {
|
||||
return sql`${left} >= ${bindIfParam(right, left)}`;
|
||||
};
|
||||
const lt = (left, right) => {
|
||||
return sql`${left} < ${bindIfParam(right, left)}`;
|
||||
};
|
||||
const lte = (left, right) => {
|
||||
return sql`${left} <= ${bindIfParam(right, left)}`;
|
||||
};
|
||||
function inArray(column, values) {
|
||||
if (Array.isArray(values)) {
|
||||
if (values.length === 0) {
|
||||
return sql`false`;
|
||||
}
|
||||
return sql`${column} in ${values.map((v) => bindIfParam(v, column))}`;
|
||||
}
|
||||
return sql`${column} in ${bindIfParam(values, column)}`;
|
||||
}
|
||||
function notInArray(column, values) {
|
||||
if (Array.isArray(values)) {
|
||||
if (values.length === 0) {
|
||||
return sql`true`;
|
||||
}
|
||||
return sql`${column} not in ${values.map((v) => bindIfParam(v, column))}`;
|
||||
}
|
||||
return sql`${column} not in ${bindIfParam(values, column)}`;
|
||||
}
|
||||
function isNull(value) {
|
||||
return sql`${value} is null`;
|
||||
}
|
||||
function isNotNull(value) {
|
||||
return sql`${value} is not null`;
|
||||
}
|
||||
function exists(subquery) {
|
||||
return sql`exists ${subquery}`;
|
||||
}
|
||||
function notExists(subquery) {
|
||||
return sql`not exists ${subquery}`;
|
||||
}
|
||||
function between(column, min, max) {
|
||||
return sql`${column} between ${bindIfParam(min, column)} and ${bindIfParam(
|
||||
max,
|
||||
column
|
||||
)}`;
|
||||
}
|
||||
function notBetween(column, min, max) {
|
||||
return sql`${column} not between ${bindIfParam(
|
||||
min,
|
||||
column
|
||||
)} and ${bindIfParam(max, column)}`;
|
||||
}
|
||||
function like(column, value) {
|
||||
return sql`${column} like ${value}`;
|
||||
}
|
||||
function notLike(column, value) {
|
||||
return sql`${column} not like ${value}`;
|
||||
}
|
||||
function ilike(column, value) {
|
||||
return sql`${column} ilike ${value}`;
|
||||
}
|
||||
function notIlike(column, value) {
|
||||
return sql`${column} not ilike ${value}`;
|
||||
}
|
||||
function arrayContains(column, values) {
|
||||
if (Array.isArray(values)) {
|
||||
if (values.length === 0) {
|
||||
throw new Error("arrayContains requires at least one value");
|
||||
}
|
||||
const array = sql`${bindIfParam(values, column)}`;
|
||||
return sql`${column} @> ${array}`;
|
||||
}
|
||||
return sql`${column} @> ${bindIfParam(values, column)}`;
|
||||
}
|
||||
function arrayContained(column, values) {
|
||||
if (Array.isArray(values)) {
|
||||
if (values.length === 0) {
|
||||
throw new Error("arrayContained requires at least one value");
|
||||
}
|
||||
const array = sql`${bindIfParam(values, column)}`;
|
||||
return sql`${column} <@ ${array}`;
|
||||
}
|
||||
return sql`${column} <@ ${bindIfParam(values, column)}`;
|
||||
}
|
||||
function arrayOverlaps(column, values) {
|
||||
if (Array.isArray(values)) {
|
||||
if (values.length === 0) {
|
||||
throw new Error("arrayOverlaps requires at least one value");
|
||||
}
|
||||
const array = sql`${bindIfParam(values, column)}`;
|
||||
return sql`${column} && ${array}`;
|
||||
}
|
||||
return sql`${column} && ${bindIfParam(values, column)}`;
|
||||
}
|
||||
export {
|
||||
and,
|
||||
arrayContained,
|
||||
arrayContains,
|
||||
arrayOverlaps,
|
||||
between,
|
||||
bindIfParam,
|
||||
eq,
|
||||
exists,
|
||||
gt,
|
||||
gte,
|
||||
ilike,
|
||||
inArray,
|
||||
isNotNull,
|
||||
isNull,
|
||||
like,
|
||||
lt,
|
||||
lte,
|
||||
ne,
|
||||
not,
|
||||
notBetween,
|
||||
notExists,
|
||||
notIlike,
|
||||
notInArray,
|
||||
notLike,
|
||||
or
|
||||
};
|
||||
//# sourceMappingURL=conditions.js.map
|
||||
1
node_modules/drizzle-orm/sql/expressions/conditions.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/sql/expressions/conditions.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
25
node_modules/drizzle-orm/sql/expressions/index.cjs
generated
vendored
Normal file
25
node_modules/drizzle-orm/sql/expressions/index.cjs
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var expressions_exports = {};
|
||||
module.exports = __toCommonJS(expressions_exports);
|
||||
__reExport(expressions_exports, require("./conditions.cjs"), module.exports);
|
||||
__reExport(expressions_exports, require("./select.cjs"), module.exports);
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
...require("./conditions.cjs"),
|
||||
...require("./select.cjs")
|
||||
});
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
1
node_modules/drizzle-orm/sql/expressions/index.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/sql/expressions/index.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/sql/expressions/index.ts"],"sourcesContent":["export * from './conditions.ts';\nexport * from './select.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gCAAc,4BAAd;AACA,gCAAc,wBADd;","names":[]}
|
||||
2
node_modules/drizzle-orm/sql/expressions/index.d.cts
generated
vendored
Normal file
2
node_modules/drizzle-orm/sql/expressions/index.d.cts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./conditions.cjs";
|
||||
export * from "./select.cjs";
|
||||
2
node_modules/drizzle-orm/sql/expressions/index.d.ts
generated
vendored
Normal file
2
node_modules/drizzle-orm/sql/expressions/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./conditions.js";
|
||||
export * from "./select.js";
|
||||
3
node_modules/drizzle-orm/sql/expressions/index.js
generated
vendored
Normal file
3
node_modules/drizzle-orm/sql/expressions/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export * from "./conditions.js";
|
||||
export * from "./select.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/drizzle-orm/sql/expressions/index.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/sql/expressions/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/sql/expressions/index.ts"],"sourcesContent":["export * from './conditions.ts';\nexport * from './select.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
||||
37
node_modules/drizzle-orm/sql/expressions/select.cjs
generated
vendored
Normal file
37
node_modules/drizzle-orm/sql/expressions/select.cjs
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc2) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var select_exports = {};
|
||||
__export(select_exports, {
|
||||
asc: () => asc,
|
||||
desc: () => desc
|
||||
});
|
||||
module.exports = __toCommonJS(select_exports);
|
||||
var import_sql = require("../sql.cjs");
|
||||
function asc(column) {
|
||||
return import_sql.sql`${column} asc`;
|
||||
}
|
||||
function desc(column) {
|
||||
return import_sql.sql`${column} desc`;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
asc,
|
||||
desc
|
||||
});
|
||||
//# sourceMappingURL=select.cjs.map
|
||||
1
node_modules/drizzle-orm/sql/expressions/select.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/sql/expressions/select.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/sql/expressions/select.ts"],"sourcesContent":["import type { AnyColumn } from '../../column.ts';\nimport type { SQL, SQLWrapper } from '../sql.ts';\nimport { sql } from '../sql.ts';\n\n/**\n * Used in sorting, this specifies that the given\n * column or expression should be sorted in ascending\n * order. By the SQL standard, ascending order is the\n * default, so it is not usually necessary to specify\n * ascending sort order.\n *\n * ## Examples\n *\n * ```ts\n * // Return cars, starting with the oldest models\n * // and going in ascending order to the newest.\n * db.select().from(cars)\n * .orderBy(asc(cars.year));\n * ```\n *\n * @see desc to sort in descending order\n */\nexport function asc(column: AnyColumn | SQLWrapper): SQL {\n\treturn sql`${column} asc`;\n}\n\n/**\n * Used in sorting, this specifies that the given\n * column or expression should be sorted in descending\n * order.\n *\n * ## Examples\n *\n * ```ts\n * // Select users, with the most recently created\n * // records coming first.\n * db.select().from(users)\n * .orderBy(desc(users.createdAt));\n * ```\n *\n * @see asc to sort in ascending order\n */\nexport function desc(column: AnyColumn | SQLWrapper): SQL {\n\treturn sql`${column} desc`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAoB;AAoBb,SAAS,IAAI,QAAqC;AACxD,SAAO,iBAAM,MAAM;AACpB;AAkBO,SAAS,KAAK,QAAqC;AACzD,SAAO,iBAAM,MAAM;AACpB;","names":[]}
|
||||
38
node_modules/drizzle-orm/sql/expressions/select.d.cts
generated
vendored
Normal file
38
node_modules/drizzle-orm/sql/expressions/select.d.cts
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
import type { AnyColumn } from "../../column.cjs";
|
||||
import type { SQL, SQLWrapper } from "../sql.cjs";
|
||||
/**
|
||||
* Used in sorting, this specifies that the given
|
||||
* column or expression should be sorted in ascending
|
||||
* order. By the SQL standard, ascending order is the
|
||||
* default, so it is not usually necessary to specify
|
||||
* ascending sort order.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Return cars, starting with the oldest models
|
||||
* // and going in ascending order to the newest.
|
||||
* db.select().from(cars)
|
||||
* .orderBy(asc(cars.year));
|
||||
* ```
|
||||
*
|
||||
* @see desc to sort in descending order
|
||||
*/
|
||||
export declare function asc(column: AnyColumn | SQLWrapper): SQL;
|
||||
/**
|
||||
* Used in sorting, this specifies that the given
|
||||
* column or expression should be sorted in descending
|
||||
* order.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select users, with the most recently created
|
||||
* // records coming first.
|
||||
* db.select().from(users)
|
||||
* .orderBy(desc(users.createdAt));
|
||||
* ```
|
||||
*
|
||||
* @see asc to sort in ascending order
|
||||
*/
|
||||
export declare function desc(column: AnyColumn | SQLWrapper): SQL;
|
||||
38
node_modules/drizzle-orm/sql/expressions/select.d.ts
generated
vendored
Normal file
38
node_modules/drizzle-orm/sql/expressions/select.d.ts
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
import type { AnyColumn } from "../../column.js";
|
||||
import type { SQL, SQLWrapper } from "../sql.js";
|
||||
/**
|
||||
* Used in sorting, this specifies that the given
|
||||
* column or expression should be sorted in ascending
|
||||
* order. By the SQL standard, ascending order is the
|
||||
* default, so it is not usually necessary to specify
|
||||
* ascending sort order.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Return cars, starting with the oldest models
|
||||
* // and going in ascending order to the newest.
|
||||
* db.select().from(cars)
|
||||
* .orderBy(asc(cars.year));
|
||||
* ```
|
||||
*
|
||||
* @see desc to sort in descending order
|
||||
*/
|
||||
export declare function asc(column: AnyColumn | SQLWrapper): SQL;
|
||||
/**
|
||||
* Used in sorting, this specifies that the given
|
||||
* column or expression should be sorted in descending
|
||||
* order.
|
||||
*
|
||||
* ## Examples
|
||||
*
|
||||
* ```ts
|
||||
* // Select users, with the most recently created
|
||||
* // records coming first.
|
||||
* db.select().from(users)
|
||||
* .orderBy(desc(users.createdAt));
|
||||
* ```
|
||||
*
|
||||
* @see asc to sort in ascending order
|
||||
*/
|
||||
export declare function desc(column: AnyColumn | SQLWrapper): SQL;
|
||||
12
node_modules/drizzle-orm/sql/expressions/select.js
generated
vendored
Normal file
12
node_modules/drizzle-orm/sql/expressions/select.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
import { sql } from "../sql.js";
|
||||
function asc(column) {
|
||||
return sql`${column} asc`;
|
||||
}
|
||||
function desc(column) {
|
||||
return sql`${column} desc`;
|
||||
}
|
||||
export {
|
||||
asc,
|
||||
desc
|
||||
};
|
||||
//# sourceMappingURL=select.js.map
|
||||
1
node_modules/drizzle-orm/sql/expressions/select.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/sql/expressions/select.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/sql/expressions/select.ts"],"sourcesContent":["import type { AnyColumn } from '../../column.ts';\nimport type { SQL, SQLWrapper } from '../sql.ts';\nimport { sql } from '../sql.ts';\n\n/**\n * Used in sorting, this specifies that the given\n * column or expression should be sorted in ascending\n * order. By the SQL standard, ascending order is the\n * default, so it is not usually necessary to specify\n * ascending sort order.\n *\n * ## Examples\n *\n * ```ts\n * // Return cars, starting with the oldest models\n * // and going in ascending order to the newest.\n * db.select().from(cars)\n * .orderBy(asc(cars.year));\n * ```\n *\n * @see desc to sort in descending order\n */\nexport function asc(column: AnyColumn | SQLWrapper): SQL {\n\treturn sql`${column} asc`;\n}\n\n/**\n * Used in sorting, this specifies that the given\n * column or expression should be sorted in descending\n * order.\n *\n * ## Examples\n *\n * ```ts\n * // Select users, with the most recently created\n * // records coming first.\n * db.select().from(users)\n * .orderBy(desc(users.createdAt));\n * ```\n *\n * @see asc to sort in ascending order\n */\nexport function desc(column: AnyColumn | SQLWrapper): SQL {\n\treturn sql`${column} desc`;\n}\n"],"mappings":"AAEA,SAAS,WAAW;AAoBb,SAAS,IAAI,QAAqC;AACxD,SAAO,MAAM,MAAM;AACpB;AAkBO,SAAS,KAAK,QAAqC;AACzD,SAAO,MAAM,MAAM;AACpB;","names":[]}
|
||||
Reference in New Issue
Block a user