rado 0.4.9 → 1.0.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Builder.d.ts +36 -0
- package/dist/core/Builder.js +99 -0
- package/dist/core/Column.d.ts +38 -0
- package/dist/core/Column.js +59 -0
- package/dist/core/Constraint.d.ts +39 -0
- package/dist/core/Constraint.js +87 -0
- package/dist/core/Database.d.ts +43 -0
- package/dist/core/Database.js +58 -0
- package/dist/core/Dialect.d.ts +6 -0
- package/dist/core/Dialect.js +16 -0
- package/dist/core/Driver.d.ts +28 -0
- package/dist/core/Emitter.d.ts +35 -0
- package/dist/core/Emitter.js +153 -0
- package/dist/core/Index.d.ts +28 -0
- package/dist/core/Index.js +50 -0
- package/dist/core/Internal.d.ts +67 -0
- package/dist/core/Internal.js +62 -0
- package/dist/core/MetaData.d.ts +27 -0
- package/dist/core/Param.d.ts +9 -0
- package/dist/core/Param.js +14 -0
- package/dist/core/Query.d.ts +40 -0
- package/dist/core/Query.js +70 -0
- package/dist/core/Resolver.d.ts +23 -0
- package/dist/core/Resolver.js +54 -0
- package/dist/core/Schema.d.ts +4 -0
- package/dist/core/Schema.js +13 -0
- package/dist/core/Selection.d.ts +27 -0
- package/dist/core/Selection.js +88 -0
- package/dist/core/Sql.d.ts +49 -0
- package/dist/core/Sql.js +153 -0
- package/dist/core/Table.d.ts +56 -0
- package/dist/core/Table.js +103 -0
- package/dist/core/Types.d.ts +3 -0
- package/dist/core/Virtual.d.ts +2 -0
- package/dist/core/Virtual.js +28 -0
- package/dist/core/expr/Aggregate.d.ts +10 -0
- package/dist/core/expr/Aggregate.js +38 -0
- package/dist/core/expr/Conditions.d.ts +40 -0
- package/dist/core/expr/Conditions.js +137 -0
- package/dist/core/expr/Field.d.ts +14 -0
- package/dist/core/expr/Field.js +15 -0
- package/dist/core/expr/Functions.d.ts +6 -0
- package/dist/core/expr/Functions.js +11 -0
- package/dist/core/expr/Input.d.ts +3 -0
- package/dist/core/expr/Input.js +14 -0
- package/dist/core/query/CreateTable.d.ts +13 -0
- package/dist/core/query/CreateTable.js +23 -0
- package/dist/core/query/Delete.d.ts +19 -0
- package/dist/core/query/Delete.js +44 -0
- package/dist/core/query/DropTable.d.ts +13 -0
- package/dist/core/query/DropTable.js +23 -0
- package/dist/core/query/Insert.d.ts +43 -0
- package/dist/core/query/Insert.js +111 -0
- package/dist/core/query/Select.d.ts +93 -0
- package/dist/core/query/Select.js +196 -0
- package/dist/core/query/Union.d.ts +27 -0
- package/dist/core/query/Union.js +86 -0
- package/dist/core/query/Update.d.ts +23 -0
- package/dist/core/query/Update.js +55 -0
- package/dist/driver/better-sqlite3.d.ts +3 -16
- package/dist/driver/better-sqlite3.js +27 -33
- package/dist/driver/bun-sqlite.d.ts +3 -18
- package/dist/driver/bun-sqlite.js +26 -42
- package/dist/driver/pg.d.ts +25 -0
- package/dist/driver/pg.js +81 -0
- package/dist/driver/pglite.d.ts +24 -0
- package/dist/driver/pglite.js +59 -0
- package/dist/driver/sql.js.d.ts +3 -16
- package/dist/driver/sql.js.js +41 -47
- package/dist/index.d.ts +16 -21
- package/dist/index.js +16 -14
- package/dist/migrate/Scan.d.ts +1 -0
- package/dist/migrate/Scan.js +0 -0
- package/dist/postgres/PostgresColumns.d.ts +10 -0
- package/dist/postgres/PostgresColumns.js +58 -0
- package/dist/postgres/PostgresDialect.d.ts +2 -0
- package/dist/postgres/PostgresDialect.js +58 -0
- package/dist/postgres/PostgresSchema.d.ts +1 -0
- package/dist/postgres/PostgresSchema.js +4 -0
- package/dist/postgres/PostgresTable.d.ts +1 -0
- package/dist/postgres/PostgresTable.js +4 -0
- package/dist/postgres.d.ts +2 -0
- package/dist/postgres.js +2 -0
- package/dist/sqlite/SqliteColumns.d.ts +9 -0
- package/dist/sqlite/SqliteColumns.js +63 -0
- package/dist/sqlite/SqliteDialect.d.ts +2 -0
- package/dist/sqlite/SqliteDialect.js +51 -0
- package/dist/sqlite/SqliteFunctions.d.ts +8 -167
- package/dist/sqlite/SqliteFunctions.js +6 -3
- package/dist/sqlite/SqliteTable.d.ts +1 -0
- package/dist/sqlite/SqliteTable.js +4 -0
- package/dist/sqlite.d.ts +3 -2
- package/dist/sqlite.js +3 -2
- package/dist/src/core/Builder.d.ts +36 -0
- package/dist/src/core/Column.d.ts +38 -0
- package/dist/src/core/Constraint.d.ts +39 -0
- package/dist/src/core/Database.d.ts +43 -0
- package/dist/src/core/Dialect.d.ts +6 -0
- package/dist/src/core/Driver.d.ts +28 -0
- package/dist/src/core/Emitter.d.ts +35 -0
- package/dist/src/core/Index.d.ts +28 -0
- package/dist/src/core/Internal.d.ts +67 -0
- package/dist/src/core/MetaData.d.ts +27 -0
- package/dist/src/core/Param.d.ts +9 -0
- package/dist/src/core/Query.d.ts +40 -0
- package/dist/src/core/Resolver.d.ts +23 -0
- package/dist/src/core/Schema.d.ts +4 -0
- package/dist/src/core/Selection.d.ts +27 -0
- package/dist/src/core/Sql.d.ts +49 -0
- package/dist/src/core/Table.d.ts +56 -0
- package/dist/src/core/Types.d.ts +3 -0
- package/dist/src/core/Virtual.d.ts +2 -0
- package/dist/src/core/expr/Aggregate.d.ts +10 -0
- package/dist/src/core/expr/Conditions.d.ts +40 -0
- package/dist/src/core/expr/Field.d.ts +14 -0
- package/dist/src/core/expr/Functions.d.ts +6 -0
- package/dist/src/core/expr/Input.d.ts +3 -0
- package/dist/src/core/query/CreateTable.d.ts +13 -0
- package/dist/src/core/query/Delete.d.ts +19 -0
- package/dist/src/core/query/DropTable.d.ts +13 -0
- package/dist/src/core/query/Insert.d.ts +43 -0
- package/dist/src/core/query/Select.d.ts +93 -0
- package/dist/src/core/query/Union.d.ts +27 -0
- package/dist/src/core/query/Update.d.ts +23 -0
- package/dist/src/driver/better-sqlite3.d.ts +3 -0
- package/dist/src/driver/bun-sqlite.d.ts +4 -0
- package/dist/src/driver/pg.d.ts +25 -0
- package/dist/src/driver/pglite.d.ts +24 -0
- package/dist/src/driver/sql.js.d.ts +3 -0
- package/dist/src/index.d.ts +16 -0
- package/dist/src/migrate/Scan.d.ts +1 -0
- package/dist/src/postgres/PostgresColumns.d.ts +10 -0
- package/dist/src/postgres/PostgresDialect.d.ts +2 -0
- package/dist/src/postgres/PostgresSchema.d.ts +1 -0
- package/dist/src/postgres/PostgresTable.d.ts +1 -0
- package/dist/src/postgres.d.ts +2 -0
- package/dist/src/sqlite/SqliteColumns.d.ts +9 -0
- package/dist/src/sqlite/SqliteDialect.d.ts +2 -0
- package/dist/src/sqlite/SqliteFunctions.d.ts +8 -0
- package/dist/src/sqlite/SqliteTable.d.ts +1 -0
- package/dist/src/sqlite.d.ts +3 -0
- package/dist/src/universal/UniversalColumns.d.ts +6 -0
- package/dist/src/universal/UniversalTransaction.d.ts +3 -0
- package/dist/src/universal.d.ts +2 -0
- package/dist/test/Suite.d.ts +11 -0
- package/dist/test/TestDriver.d.ts +2 -0
- package/dist/test/TestUtils.d.ts +4 -0
- package/dist/test/core/Expr.test.d.ts +1 -0
- package/dist/test/core/Selection.test.d.ts +1 -0
- package/dist/test/core/Sql.test.d.ts +1 -0
- package/dist/test/core/SqliteFunctions.test.d.ts +1 -0
- package/dist/test/core/Table.test.d.ts +1 -0
- package/dist/test/driver/better-sqlite3.test.d.ts +1 -0
- package/dist/test/driver/bun-sqlite.test.d.ts +1 -0
- package/dist/test/driver/pg.test.d.ts +1 -0
- package/dist/test/driver/pglite.test.d.ts +1 -0
- package/dist/test/driver/sql.js.test.d.ts +1 -0
- package/dist/test/query/CreateTable.test.d.ts +1 -0
- package/dist/test/query/Delete.test.d.ts +1 -0
- package/dist/test/query/DropTable.test.d.ts +1 -0
- package/dist/test/query/Insert.test.d.ts +1 -0
- package/dist/test/query/Select.test.d.ts +1 -0
- package/dist/test/query/Union.test.d.ts +1 -0
- package/dist/test/query/Update.test.d.ts +1 -0
- package/dist/universal/UniversalColumns.d.ts +6 -0
- package/dist/universal/UniversalColumns.js +56 -0
- package/dist/universal/UniversalTransaction.d.ts +3 -0
- package/dist/universal/UniversalTransaction.js +14 -0
- package/dist/universal.d.ts +2 -0
- package/dist/universal.js +2 -0
- package/package.json +25 -43
- package/dist/define/Column.d.ts +0 -122
- package/dist/define/Column.js +0 -183
- package/dist/define/Expr.d.ts +0 -185
- package/dist/define/Expr.js +0 -463
- package/dist/define/Fields.d.ts +0 -18
- package/dist/define/Functions.d.ts +0 -5
- package/dist/define/Functions.js +0 -12
- package/dist/define/Id.d.ts +0 -3
- package/dist/define/Index.d.ts +0 -17
- package/dist/define/Index.js +0 -19
- package/dist/define/Ops.d.ts +0 -36
- package/dist/define/Ops.js +0 -114
- package/dist/define/OrderBy.d.ts +0 -9
- package/dist/define/OrderBy.js +0 -8
- package/dist/define/Param.d.ts +0 -18
- package/dist/define/Param.js +0 -27
- package/dist/define/Query.d.ts +0 -268
- package/dist/define/Query.js +0 -596
- package/dist/define/Schema.d.ts +0 -12
- package/dist/define/Schema.js +0 -140
- package/dist/define/Selection.d.ts +0 -21
- package/dist/define/Selection.js +0 -6
- package/dist/define/Sql.d.ts +0 -6
- package/dist/define/Sql.js +0 -21
- package/dist/define/Table.d.ts +0 -75
- package/dist/define/Table.js +0 -138
- package/dist/define/Target.d.ts +0 -47
- package/dist/define/Target.js +0 -68
- package/dist/define/VirtualTable.d.ts +0 -31
- package/dist/define/VirtualTable.js +0 -39
- package/dist/driver/@sqlite.org/sqlite-wasm.d.ts +0 -17
- package/dist/driver/@sqlite.org/sqlite-wasm.js +0 -80
- package/dist/driver/d1.d.ts +0 -22
- package/dist/driver/d1.js +0 -71
- package/dist/driver/sqlite3.d.ts +0 -22
- package/dist/driver/sqlite3.js +0 -132
- package/dist/lib/Driver.d.ts +0 -111
- package/dist/lib/Driver.js +0 -398
- package/dist/lib/Formatter.d.ts +0 -106
- package/dist/lib/Formatter.js +0 -898
- package/dist/lib/Sanitizer.d.ts +0 -5
- package/dist/lib/SqlError.d.ts +0 -3
- package/dist/lib/SqlError.js +0 -10
- package/dist/lib/Statement.d.ts +0 -108
- package/dist/lib/Statement.js +0 -190
- package/dist/sqlite/SqliteFormatter.d.ts +0 -11
- package/dist/sqlite/SqliteFormatter.js +0 -66
- package/dist/sqlite/SqliteSchema.d.ts +0 -25
- package/dist/sqlite/SqliteSchema.js +0 -46
- package/dist/util/Alias.d.ts +0 -1
- package/dist/util/Alias.js +0 -6
- package/dist/util/Callable.d.ts +0 -16
- package/dist/util/Callable.js +0 -9
- /package/dist/{define/Fields.js → core/Driver.js} +0 -0
- /package/dist/{define/Id.js → core/MetaData.js} +0 -0
- /package/dist/{lib/Sanitizer.js → core/Types.js} +0 -0
|
@@ -1,167 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare const
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
iif<T>(x: EV<boolean>, y: EV<T>, z: EV<T>): Expr<T>;
|
|
10
|
-
/**
|
|
11
|
-
* The EXISTS operator always evaluates to one of the integer values 0 and 1. If executing the SELECT statement specified as the right-hand operand of the EXISTS operator would return one or more rows, then the EXISTS operator evaluates to 1. If executing the SELECT would return no rows at all, then the EXISTS operator evaluates to 0.
|
|
12
|
-
*/
|
|
13
|
-
exists(cursor: Query<any>): Expr<boolean>;
|
|
14
|
-
/** Use the match operator for the FTS5 module */
|
|
15
|
-
match(table: Table<any>, searchTerm: EV<string>): Expr<boolean>;
|
|
16
|
-
/** Returns a real value reflecting the accuracy of the current match */
|
|
17
|
-
bm25(table: Table<any>, ...weights: Array<EV<number>>): Expr<number>;
|
|
18
|
-
/** The highlight() function returns a copy of the text from a specified column of the current row with extra markup text inserted to mark the start and end of phrase matches. */
|
|
19
|
-
highlight(table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>): Expr<string>;
|
|
20
|
-
/** The snippet() function is similar to highlight(), except that instead of returning entire column values, it automatically selects and extracts a short fragment of document text to process and return. */
|
|
21
|
-
snippet(table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>, snip: EV<string>, maxTokens: EV<number>): Expr<string>;
|
|
22
|
-
cast(x: EV<any>, type: 'text'): Expr<string>;
|
|
23
|
-
cast(x: EV<any>, type: 'real'): Expr<number>;
|
|
24
|
-
cast(x: EV<any>, type: 'integer'): Expr<number>;
|
|
25
|
-
cast(x: EV<any>, type: 'numeric'): Expr<number>;
|
|
26
|
-
/** The abs(X) function returns the absolute value of the numeric argument X. Abs(X) returns NULL if X is NULL. Abs(X) returns 0.0 if X is a string or blob that cannot be converted to a numeric value. If X is the numbereger -9223372036854775808 then abs(X) throws an numbereger overflow error since there is no equivalent positive 64-bit two complement value.*/
|
|
27
|
-
abs(x: EV<number>): Expr<number>;
|
|
28
|
-
/** The changes() function returns the number of database rows that were changed or inserted or deleted by the most recently completed INSERT, DELETE, or UPDATE statement, exclusive of statements in lower-level triggers. The changes() SQL function is a wrapper around the sqlite3_changes() C/C++ function and hence follows the same rules for counting changes.*/
|
|
29
|
-
changes(): Expr<number>;
|
|
30
|
-
/** The char(X1,X2,...,XN) function returns a string composed of characters having the unicode code ponumber values of numberegers X1 through XN, respectively.*/
|
|
31
|
-
char(...arg: Array<EV<number>>): Expr<string>;
|
|
32
|
-
/** The coalesce() function returns a copy of its first non-NULL argument, or NULL if all arguments are NULL. Coalesce() must have at least 2 arguments.*/
|
|
33
|
-
coalesce(x: EV<any>, y: EV<any>, ...rest: EV<any>): Expr<any>;
|
|
34
|
-
/** The hex() function numbererprets its argument as a BLOB and returns a string which is the upper-case hexadecimal rendering of the content of that blob. If the argument X in "hex(X)" is an numbereger or numbering ponumber number, then "numbererprets its argument as a BLOB" means that the binary number is first converted numbero a UTF8 text representation, then that text is numbererpreted as a BLOB. Hence, "hex(12345678)" renders as "3132333435363738" not the binary representation of the numbereger value "0000000000BC614E".*/
|
|
35
|
-
/** The ifnull() function returns a copy of its first non-NULL argument, or NULL if both arguments are NULL. Ifnull() must have exactly 2 arguments. The ifnull() function is equivalent to coalesce() with two arguments.*/
|
|
36
|
-
ifnull<T>(x: EV<T>, y: EV<T>): Expr<T>;
|
|
37
|
-
/** The instr(X,Y) function finds the first occurrence of string Y within string X and returns the number of prior characters plus 1, or 0 if Y is nowhere found within X. Or, if X and Y are both BLOBs, then instr(X,Y) returns one more than the number bytes prior to the first occurrence of Y, or 0 if Y does not occur anywhere within X. If both arguments X and Y to instr(X,Y) are non-NULL and are not BLOBs then both are numbererpreted as strings. If either X or Y are NULL in instr(X,Y) then the result is NULL.*/
|
|
38
|
-
instr(x: EV<string>, y: EV<string>): Expr<number>;
|
|
39
|
-
/** The last_insert_rowid() function returns the ROWID of the last row insert from the database connection which invoked the function. The last_insert_rowid() SQL function is a wrapper around the sqlite3_last_insert_rowid() C/C++ numbererface function.*/
|
|
40
|
-
last_insert_rowid(): Expr<number>;
|
|
41
|
-
/** For a string value X, the length(X) function returns the number of characters (not bytes) in X prior to the first NUL character. Since SQLite strings do not normally contain NUL characters, the length(X) function will usually return the total number of characters in the string X. For a blob value X, length(X) returns the number of bytes in the blob. If X is NULL then length(X) is NULL. If X is numeric then length(X) returns the length of a string representation of X.*/
|
|
42
|
-
length(x: EV<string>): Expr<number>;
|
|
43
|
-
/** The likelihood(X,Y) function returns argument X unchanged. The value Y in likelihood(X,Y) must be a numbering ponumber constant between 0.0 and 1.0, inclusive. The likelihood(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles during run-time (that is, during calls to sqlite3_step()). The purpose of the likelihood(X,Y) function is to provide a hnumber to the query planner that the argument X is a boolean that is true with a probability of approximately Y. The unlikely(X) function is short-hand for likelihood(X,0.0625). The likely(X) function is short-hand for likelihood(X,0.9375).*/
|
|
44
|
-
likelihood(x: EV<boolean>, y: number): Expr<boolean>;
|
|
45
|
-
/** The likely(X) function returns the argument X unchanged. The likely(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles at run-time (that is, during calls to sqlite3_step()). The purpose of the likely(X) function is to provide a hnumber to the query planner that the argument X is a boolean value that is usually true. The likely(X) function is equivalent to likelihood(X,0.9375). See also: unlikely(X).*/
|
|
46
|
-
likely(x: EV<boolean>): Expr<boolean>;
|
|
47
|
-
/** The lower(X) function returns a copy of string X with all ASCII characters converted to lower case. The default built-in lower() function works for ASCII characters only. To do case conversions on non-ASCII characters, load the ICU extension.*/
|
|
48
|
-
lower(x: EV<string>): Expr<string>;
|
|
49
|
-
/** The ltrim(X,Y) function returns a string formed by removing any and all characters that appear in Y from the left side of X. If the Y argument is omitted, ltrim(X) removes spaces from the left side of X.**/
|
|
50
|
-
ltrim(x: EV<string>, y?: EV<string>): Expr<string>;
|
|
51
|
-
/** The multi-argument max() function returns the argument with the maximum value, or return NULL if any argument is NULL. The multi-argument max() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to max() define a collating function, then the BINARY collating function is used. Note that max() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument.*/
|
|
52
|
-
max<T>(x: EV<T>, ...rest: Array<EV<T>>): Expr<T>;
|
|
53
|
-
/** The multi-argument min() function returns the argument with the minimum value. The multi-argument min() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to min() define a collating function, then the BINARY collating function is used. Note that min() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument.*/
|
|
54
|
-
min<T>(x: EV<T>, ...rest: Array<EV<T>>): Expr<T>;
|
|
55
|
-
/** The nullif(X,Y) function returns its first argument if the arguments are different and NULL if the arguments are the same. The nullif(X,Y) function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If neither argument to nullif() defines a collating function then the BINARY is used.*/
|
|
56
|
-
nullif<T>(x: EV<T>, y: EV<T>): Expr<T | null>;
|
|
57
|
-
/** The prnumberf(FORMAT,...) SQL function works like the sqlite3_mprnumberf() C-language function and the prnumberf() function from the standard C library. The first argument is a format string that specifies how to construct the output string using values taken from subsequent arguments. If the FORMAT argument is missing or NULL then the result is NULL. The %n format is silently ignored and does not consume an argument. The %p format is an alias for %X. The %z format is numbererchangeable with %s. If there are too few arguments in the argument list, missing arguments are assumed to have a NULL value, which is translated numbero 0 or 0.0 for numeric formats or an empty string for %s. See the built-in prnumberf() documentation for additional information.*/
|
|
58
|
-
prnumberf(format: string, ...rest: Array<Expr<any>>): Expr<string>;
|
|
59
|
-
/** The quote(X) function returns the text of an SQL literal which is the value of its argument suitable for inclusion numbero an SQL statement. strings are surrounded by single-quotes with escapes on numbererior quotes as needed. BLOBs are encoded as hexadecimal literals. strings with embedded NUL characters cannot be represented as string literals in SQL and hence the returned string literal is truncated prior to the first NUL.*/
|
|
60
|
-
quote(x: EV<string>): Expr<string>;
|
|
61
|
-
/** The random() function returns a pseudo-random numbereger between -9223372036854775808 and +9223372036854775807.*/
|
|
62
|
-
random(): Expr<number>;
|
|
63
|
-
/** The randomblob(N) function return an N-byte blob containing pseudo-random bytes. If N is less than 1 then a 1-byte random blob is returned.*/
|
|
64
|
-
/** The replace(X,Y,Z) function returns a string formed by substituting string Z for every occurrence of string Y in string X. The BINARY collating sequence is used for comparisons. If Y is an empty string then return X unchanged. If Z is not initially a string, it is cast to a UTF-8 string prior to processing.*/
|
|
65
|
-
replace(x: EV<string>, y: EV<string>, z: EV<string>): Expr<string>;
|
|
66
|
-
/** The round(X,Y) function returns a numbering-ponumber value X rounded to Y digits to the right of the decimal ponumber. If the Y argument is omitted, it is assumed to be 0.*/
|
|
67
|
-
round(x: EV<number>, y?: EV<number>): Expr<number>;
|
|
68
|
-
/** The rtrim(X,Y) function returns a string formed by removing any and all characters that appear in Y from the right side of X. If the Y argument is omitted, rtrim(X) removes spaces from the right side of X.*/
|
|
69
|
-
rtrim(x: EV<string>, y?: EV<string>): Expr<string>;
|
|
70
|
-
/** The sign(X) function returns -1, 0, or +1 if the argument X is a numeric value that is negative, zero, or positive, respectively. If the argument to sign(X) is NULL or is a string or blob that cannot be losslessly converted numbero a number, then sign(X) return NULL.*/
|
|
71
|
-
sign(x: EV<number>): Expr<number>;
|
|
72
|
-
/** The soundex(X) function returns a string that is the soundex encoding of the string X. The string "?000" is returned if the argument is NULL or contains no ASCII alphabetic characters. This function is omitted from SQLite by default. It is only available if the SQLITE_SOUNDEX compile-time option is used when SQLite is built.*/
|
|
73
|
-
soundex(x: EV<string>): Expr<string>;
|
|
74
|
-
/** The sqlite_version() function returns the version string for the SQLite library that is running. This function is an SQL wrapper around the sqlite3_libversion() C-numbererface.*/
|
|
75
|
-
sqlite_version(): Expr<string>;
|
|
76
|
-
/** The substr(X,Y,Z) function returns a substring of input string X that begins with the Y-th character and which is Z characters long. If Z is omitted then substr(X,Y) returns all characters through the end of the string X beginning with the Y-th. The left-most character of X is number 1. If Y is negative then the first character of the substring is found by counting from the right rather than the left. If Z is negative then the abs(Z) characters preceding the Y-th character are returned. If X is a string then characters indices refer to actual UTF-8 characters. If X is a BLOB then the indices refer to bytes.*/
|
|
77
|
-
substr(x: EV<string>, y: EV<number>, z?: EV<number>): Expr<string>;
|
|
78
|
-
/** The total_changes() function returns the number of row changes caused by INSERT, UPDATE or DELETE statements since the current database connection was opened. This function is a wrapper around the sqlite3_total_changes() C/C++ numbererface.*/
|
|
79
|
-
total_changes(): Expr<number>;
|
|
80
|
-
/** The trim(X,Y) function returns a string formed by removing any and all characters that appear in Y from both ends of X. If the Y argument is omitted, trim(X) removes spaces from both ends of X.*/
|
|
81
|
-
trim(x: EV<string>, Y: EV<string>): Expr<string>;
|
|
82
|
-
/** The typeof(X) function returns a string that indicates the datatype of the Expr X: "null", "numbereger", "real", "text", or "blob".*/
|
|
83
|
-
typeof(x: EV<any>): Expr<string>;
|
|
84
|
-
/** The unicode(X) function returns the numeric unicode code ponumber corresponding to the first character of the string X. If the argument to unicode(X) is not a string then the result is undefined.*/
|
|
85
|
-
unicode(x: EV<string>): Expr<number>;
|
|
86
|
-
/** The unlikely(X) function returns the argument X unchanged. The unlikely(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles at run-time (that is, during calls to sqlite3_step()). The purpose of the unlikely(X) function is to provide a hnumber to the query planner that the argument X is a boolean value that is usually not true. The unlikely(X) function is equivalent to likelihood(X, 0.0625).*/
|
|
87
|
-
unlikely(x: EV<boolean>): Expr<boolean>;
|
|
88
|
-
/** The upper(X) function returns a copy of input string X in which all lower-case ASCII characters are converted to their upper-case equivalent.*/
|
|
89
|
-
upper(x: EV<string>): Expr<string>;
|
|
90
|
-
/** The avg() function returns the average value of all non-NULL X within a group. string and BLOB values that do not look like numbers are numbererpreted as 0. The result of avg() is always a numbering ponumber value as long as at there is at least one non-NULL input even if all inputs are numberegers. The result of avg() is NULL if and only if there are no non-NULL inputs. */
|
|
91
|
-
avg(x: Expr<number>): Expr<number>;
|
|
92
|
-
/** The group_concat() function returns a string which is the concatenation of all non-NULL values of X. If parameter Y is present then it is used as the separator between instances of X. A comma (",") is used as the separator if Y is omitted. The order of the concatenated elements is arbitrary. */
|
|
93
|
-
group_concat(x: EV<string>, y?: EV<string>): Expr<string>;
|
|
94
|
-
/** The sum() and total() aggregate functions return sum of all non-NULL values in the group. If there are no non-NULL input rows then sum() returns NULL but total() returns 0.0. NULL is not normally a helpful result for the sum of no rows but the SQL standard requires it and most other SQL database engines implement sum() that way so SQLite does it in the same way in order to be compatible. The non-standard total() function is provided as a convenient way to work around this design problem in the SQL language.
|
|
95
|
-
|
|
96
|
-
The result of total() is always a numbering ponumber value. The result of sum() is an numbereger value if all non-NULL inputs are numberegers. If any input to sum() is neither an numbereger or a NULL then sum() returns a numbering ponumber value which might be an approximation to the true sum.
|
|
97
|
-
|
|
98
|
-
Sum() will throw an "numbereger overflow" exception if all inputs are numberegers or NULL and an numbereger overflow occurs at any ponumber during the computation. Total() never throws an numbereger overflow.
|
|
99
|
-
*/
|
|
100
|
-
sum(x: EV<number>): Expr<number>;
|
|
101
|
-
/** Return the arccosine of X. The result is in radians. */
|
|
102
|
-
acos(x: EV<number>): Expr<number>;
|
|
103
|
-
/** Return the hyperbolic arccosine of X. */
|
|
104
|
-
acosh(x: EV<number>): Expr<number>;
|
|
105
|
-
/** Return the arcsine of X. The result is in radians. */
|
|
106
|
-
asin(x: EV<number>): Expr<number>;
|
|
107
|
-
/** Return the hyperbolic arcsine of X. */
|
|
108
|
-
asinh(x: EV<number>): Expr<number>;
|
|
109
|
-
/** Return the arctangent of X. The result is in radians. */
|
|
110
|
-
atan(x: EV<number>): Expr<number>;
|
|
111
|
-
/** Return the arctangent of Y/X. The result is in radians. The result is placed numbero correct quadrant depending on the signs of X and Y. */
|
|
112
|
-
atan2(x: EV<number>, y: EV<number>): Expr<number>;
|
|
113
|
-
/** Return the hyperbolic arctangent of X. */
|
|
114
|
-
atanh(x: EV<number>): Expr<number>;
|
|
115
|
-
/** Return the first representable numbereger value greater than or equal to X. For positive values of X, this routine rounds away from zero. For negative values of X, this routine rounds toward zero. */
|
|
116
|
-
ceil(x: EV<number>): Expr<number>;
|
|
117
|
-
/** Return the cosine of X. X is in radians. */
|
|
118
|
-
cos(x: EV<number>): Expr<number>;
|
|
119
|
-
/** Return the hyperbolic cosine of X. */
|
|
120
|
-
cosh(x: EV<number>): Expr<number>;
|
|
121
|
-
/** Convert value X from radians numbero degrees. */
|
|
122
|
-
degrees(x: EV<number>): Expr<number>;
|
|
123
|
-
/** Compute e (Euler's number, approximately 2.71828182845905) raised to the power X. */
|
|
124
|
-
exp(x: EV<number>): Expr<number>;
|
|
125
|
-
/** Return the first representable numbereger value less than or equal to X. For positive numbers, this function rounds toward zero. For negative numbers, this function rounds away from zero. */
|
|
126
|
-
floor(x: EV<number>): Expr<number>;
|
|
127
|
-
/** Return the natural logarithm of X. */
|
|
128
|
-
ln(x: EV<number>): Expr<number>;
|
|
129
|
-
/**
|
|
130
|
-
Return the base-10 logarithm for X. Or, for the two-argument version, return the base-B logarithm of X.
|
|
131
|
-
Compatibility note: SQLite works like PostgreSQL in that the log() function computes a base-10 logarithm. Most other SQL database engines compute a natural logarithm for log(). In the two-argument version of log(B,X), the first argument is the base and the second argument is the operand. This is the same as in PostgreSQL and MySQL, but is reversed from SQL Server which uses the second argument as the base and the first argument as the operand.
|
|
132
|
-
*/
|
|
133
|
-
log(x: EV<number>, y?: EV<number>): Expr<number>;
|
|
134
|
-
/** Return the logarithm base-2 for the number X. */
|
|
135
|
-
log2(x: EV<number>): Expr<number>;
|
|
136
|
-
/** Return the remainder after dividing X by Y. This is similar to the '%' operator, except that it works for non-numbereger arguments. */
|
|
137
|
-
mod(x: EV<number>, y: EV<number>): Expr<number>;
|
|
138
|
-
/** Return an approximation for π. */
|
|
139
|
-
pi(): Expr<number>;
|
|
140
|
-
/** Compute X raised to the power Y. */
|
|
141
|
-
pow(x: EV<number>, y: EV<number>): Expr<number>;
|
|
142
|
-
/** Convert X from degrees numbero radians. */
|
|
143
|
-
radians(x: EV<number>): Expr<number>;
|
|
144
|
-
/** Return the sine of X. X is in radians. */
|
|
145
|
-
sin(x: EV<number>): Expr<number>;
|
|
146
|
-
/** Return the hyperbolic sine of X. */
|
|
147
|
-
sinh(x: EV<number>): Expr<number>;
|
|
148
|
-
/** Return the square root of X. NULL is returned if X is negative. */
|
|
149
|
-
sqrt(x: EV<number>): Expr<number>;
|
|
150
|
-
/** Return the tangent of X. X is in radians. */
|
|
151
|
-
tan(x: EV<number>): Expr<number>;
|
|
152
|
-
/** Return the hyperbolic tangent of X. */
|
|
153
|
-
tanh(x: EV<number>): Expr<number>;
|
|
154
|
-
/** Return the representable numbereger in between X and 0 (inclusive) that is furthest away from zero. Or, in other words, return the numbereger part of X, rounding toward zero. The trunc() function is similar to ceiling(X) and floor(X) except that it always rounds toward zero whereas ceiling(X) and floor(X) round up and down, respectively. */
|
|
155
|
-
trunc(x: EV<number>): Expr<number>;
|
|
156
|
-
date(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
|
|
157
|
-
time(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
|
|
158
|
-
datetime(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
|
|
159
|
-
julianday(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
|
|
160
|
-
strftime(format: EV<string>, timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
|
|
161
|
-
};
|
|
162
|
-
export declare const count: (x?: Expr<any>) => Expr<number>, iif: <T>(x: EV<boolean>, y: EV<T>, z: EV<T>) => Expr<T>, exists: (cursor: Query<any>) => Expr<boolean>, match: (table: Table<any>, searchTerm: EV<string>) => Expr<boolean>, bm25: (table: Table<any>, ...weights: Array<EV<number>>) => Expr<number>, highlight: (table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>) => Expr<string>, snippet: (table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>, snip: EV<string>, maxTokens: EV<number>) => Expr<string>, cast: {
|
|
163
|
-
(x: EV<any>, type: 'text'): Expr<string>;
|
|
164
|
-
(x: EV<any>, type: 'real'): Expr<number>;
|
|
165
|
-
(x: EV<any>, type: 'integer'): Expr<number>;
|
|
166
|
-
(x: EV<any>, type: 'numeric'): Expr<number>;
|
|
167
|
-
}, abs: (x: EV<number>) => Expr<number>, changes: () => Expr<number>, char: (...arg: Array<EV<number>>) => Expr<string>, coalesce: (x: EV<any>, y: EV<any>, ...rest: EV<any>) => Expr<any>, ifnull: <T>(x: EV<T>, y: EV<T>) => Expr<T>, instr: (x: EV<string>, y: EV<string>) => Expr<number>, last_insert_rowid: () => Expr<number>, length: (x: EV<string>) => Expr<number>, likelihood: (x: EV<boolean>, y: number) => Expr<boolean>, likely: (x: EV<boolean>) => Expr<boolean>, lower: (x: EV<string>) => Expr<string>, ltrim: (x: EV<string>, y?: EV<string>) => Expr<string>, max: <T>(x: EV<T>, ...rest: EV<T>[]) => Expr<T>, min: <T>(x: EV<T>, ...rest: EV<T>[]) => Expr<T>, nullif: <T>(x: EV<T>, y: EV<T>) => Expr<T | null>, prnumberf: (format: string, ...rest: Array<Expr<any>>) => Expr<string>, quote: (x: EV<string>) => Expr<string>, random: () => Expr<number>, replace: (x: EV<string>, y: EV<string>, z: EV<string>) => Expr<string>, round: (x: EV<number>, y?: EV<number>) => Expr<number>, rtrim: (x: EV<string>, y?: EV<string>) => Expr<string>, sign: (x: EV<number>) => Expr<number>, soundex: (x: EV<string>) => Expr<string>, sqlite_version: () => Expr<string>, substr: (x: EV<string>, y: EV<number>, z?: EV<number>) => Expr<string>, total_changes: () => Expr<number>, trim: (x: EV<string>, Y: EV<string>) => Expr<string>, unicode: (x: EV<string>) => Expr<number>, unlikely: (x: EV<boolean>) => Expr<boolean>, upper: (x: EV<string>) => Expr<string>, avg: (x: Expr<number>) => Expr<number>, group_concat: (x: EV<string>, y?: EV<string>) => Expr<string>, sum: (x: EV<number>) => Expr<number>, acos: (x: EV<number>) => Expr<number>, acosh: (x: EV<number>) => Expr<number>, asin: (x: EV<number>) => Expr<number>, asinh: (x: EV<number>) => Expr<number>, atan: (x: EV<number>) => Expr<number>, atan2: (x: EV<number>, y: EV<number>) => Expr<number>, atanh: (x: EV<number>) => Expr<number>, ceil: (x: EV<number>) => Expr<number>, cos: (x: EV<number>) => Expr<number>, cosh: (x: EV<number>) => Expr<number>, degrees: (x: EV<number>) => Expr<number>, exp: (x: EV<number>) => Expr<number>, floor: (x: EV<number>) => Expr<number>, ln: (x: EV<number>) => Expr<number>, log: (x: EV<number>, y?: EV<number>) => Expr<number>, log2: (x: EV<number>) => Expr<number>, mod: (x: EV<number>, y: EV<number>) => Expr<number>, pi: () => Expr<number>, pow: (x: EV<number>, y: EV<number>) => Expr<number>, radians: (x: EV<number>) => Expr<number>, sin: (x: EV<number>) => Expr<number>, sinh: (x: EV<number>) => Expr<number>, sqrt: (x: EV<number>) => Expr<number>, tan: (x: EV<number>) => Expr<number>, tanh: (x: EV<number>) => Expr<number>, trunc: (x: EV<number>) => Expr<number>, date: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, time: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, datetime: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, julianday: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, strftime: (format: EV<string>, timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>;
|
|
1
|
+
import type { HasQuery, HasSql, HasTable } from '../core/Internal.ts';
|
|
2
|
+
import { type Sql } from '../core/Sql.ts';
|
|
3
|
+
import { type Input } from '../core/expr/Input.ts';
|
|
4
|
+
export declare const count: (x?: HasSql) => Sql<number>, iif: <T>(x: Input<boolean>, y: Input<T>, z: Input<T>) => Sql<T>, exists: (cursor: HasQuery) => Sql<boolean>, match: (table: HasTable, searchTerm: Input<string>) => Sql<boolean>, bm25: (table: HasTable, ...weights: Array<Input<number>>) => Sql<number>, highlight: (table: HasTable, index: Input<number>, insertBefore: Input<string>, insertAfter: Input<string>) => Sql<string>, snippet: (table: HasTable, index: Input<number>, insertBefore: Input<string>, insertAfter: Input<string>, snip: Input<string>, maxTokens: Input<number>) => Sql<string>, abs: (x: Input<number>) => Sql<number>, changes: () => Sql<number>, char: (...arg: Array<Input<number>>) => Sql<string>, coalesce: (x: Input, y: Input, ...rest: Array<Input>) => Sql, ifnull: <T>(x: Input<T>, y: Input<T>) => Sql<T>, instr: (x: Input<string>, y: Input<string>) => Sql<number>, last_insert_rowid: () => Sql<number>, length: (x: Input<string>) => Sql<number>, likelihood: (x: Input<boolean>, y: number) => Sql<boolean>, likely: (x: Input<boolean>) => Sql<boolean>, lower: (x: Input<string>) => Sql<string>, ltrim: (x: Input<string>, y?: Input<string>) => Sql<string>, max: <T>(x: Input<T>, ...rest: Array<Input<T>>) => Sql<T>, min: <T>(x: Input<T>, ...rest: Array<Input<T>>) => Sql<T>, nullif: <T>(x: Input<T>, y: Input<T>) => Sql<T | null>, prnumberf: (format: string, ...rest: Array<HasSql>) => Sql<string>, quote: (x: Input<string>) => Sql<string>, random: () => Sql<number>, replace: (x: Input<string>, y: Input<string>, z: Input<string>) => Sql<string>, round: (x: Input<number>, y?: Input<number>) => Sql<number>, rtrim: (x: Input<string>, y?: Input<string>) => Sql<string>, sign: (x: Input<number>) => Sql<number>, soundex: (x: Input<string>) => Sql<string>, sqlite_version: () => Sql<string>, substr: (x: Input<string>, y: Input<number>, z?: Input<number>) => Sql<string>, total_changes: () => Sql<number>, trim: (x: Input<string>, Y: Input<string>) => Sql<string>, unicode: (x: Input<string>) => Sql<number>, unlikely: (x: Input<boolean>) => Sql<boolean>, upper: (x: Input<string>) => Sql<string>, avg: (x: Sql<number>) => Sql<number>, group_concat: (x: Input<string>, y?: Input<string>) => Sql<string>, sum: (x: Input<number>) => Sql<number>, acos: (x: Input<number>) => Sql<number>, acosh: (x: Input<number>) => Sql<number>, asin: (x: Input<number>) => Sql<number>, asinh: (x: Input<number>) => Sql<number>, atan: (x: Input<number>) => Sql<number>, atan2: (x: Input<number>, y: Input<number>) => Sql<number>, atanh: (x: Input<number>) => Sql<number>, ceil: (x: Input<number>) => Sql<number>, cos: (x: Input<number>) => Sql<number>, cosh: (x: Input<number>) => Sql<number>, degrees: (x: Input<number>) => Sql<number>, exp: (x: Input<number>) => Sql<number>, floor: (x: Input<number>) => Sql<number>, ln: (x: Input<number>) => Sql<number>, log: (x: Input<number>, y?: Input<number>) => Sql<number>, log2: (x: Input<number>) => Sql<number>, mod: (x: Input<number>, y: Input<number>) => Sql<number>, pi: () => Sql<number>, pow: (x: Input<number>, y: Input<number>) => Sql<number>, radians: (x: Input<number>) => Sql<number>, sin: (x: Input<number>) => Sql<number>, sinh: (x: Input<number>) => Sql<number>, sqrt: (x: Input<number>) => Sql<number>, tan: (x: Input<number>) => Sql<number>, tanh: (x: Input<number>) => Sql<number>, trunc: (x: Input<number>) => Sql<number>, date: (timeValue: Input, ...rest: Array<Input<string>>) => Sql<string>, time: (timeValue: Input, ...rest: Array<Input<string>>) => Sql<string>, datetime: (timeValue: Input, ...rest: Array<Input<string>>) => Sql<string>, julianday: (timeValue: Input, ...rest: Array<Input<string>>) => Sql<string>, strftime: (format: Input<string>, timeValue: Input, ...rest: Array<Input<string>>) => Sql<string>;
|
|
5
|
+
export declare function cast(x: Input, type: 'text'): Sql<string>;
|
|
6
|
+
export declare function cast(x: Input, type: 'real'): Sql<number>;
|
|
7
|
+
export declare function cast(x: Input, type: 'integer'): Sql<number>;
|
|
8
|
+
export declare function cast(x: Input, type: 'numeric'): Sql<number>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sql } from "../core/Sql.ts";
|
|
2
|
+
import { Functions } from "../core/expr/Functions.ts";
|
|
3
|
+
import { input } from "../core/expr/Input.ts";
|
|
2
4
|
const SqliteFunctions = Functions;
|
|
3
5
|
const {
|
|
4
6
|
count,
|
|
@@ -8,7 +10,6 @@ const {
|
|
|
8
10
|
bm25,
|
|
9
11
|
highlight,
|
|
10
12
|
snippet,
|
|
11
|
-
cast,
|
|
12
13
|
abs,
|
|
13
14
|
changes,
|
|
14
15
|
char,
|
|
@@ -74,8 +75,10 @@ const {
|
|
|
74
75
|
julianday,
|
|
75
76
|
strftime
|
|
76
77
|
} = SqliteFunctions;
|
|
78
|
+
function cast(x, type) {
|
|
79
|
+
return sql`cast(${input(x)} as ${sql.identifier(type)})`;
|
|
80
|
+
}
|
|
77
81
|
export {
|
|
78
|
-
SqliteFunctions,
|
|
79
82
|
abs,
|
|
80
83
|
acos,
|
|
81
84
|
acosh,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { table as sqliteTable } from '../core/Table.ts';
|
package/dist/sqlite.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from './sqlite/
|
|
2
|
-
export * from './sqlite/
|
|
1
|
+
export * from './sqlite/SqliteColumns.ts';
|
|
2
|
+
export * from './sqlite/SqliteDialect.ts';
|
|
3
|
+
export * from './sqlite/SqliteFunctions.ts';
|
package/dist/sqlite.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from "./sqlite/
|
|
2
|
-
export * from "./sqlite/
|
|
1
|
+
export * from "./sqlite/SqliteColumns.ts";
|
|
2
|
+
export * from "./sqlite/SqliteDialect.ts";
|
|
3
|
+
export * from "./sqlite/SqliteFunctions.ts";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { internalData, type HasQuery, type HasSql, type HasTable, type HasTarget } from './Internal.ts';
|
|
2
|
+
import type { IsPostgres, QueryMeta } from './MetaData.ts';
|
|
3
|
+
import type { QueryData } from './Query.ts';
|
|
4
|
+
import type { SelectionInput } from './Selection.ts';
|
|
5
|
+
import type { Table, TableDefinition } from './Table.ts';
|
|
6
|
+
import { Create } from './query/CreateTable.ts';
|
|
7
|
+
import { DeleteFrom } from './query/Delete.ts';
|
|
8
|
+
import { Drop } from './query/DropTable.ts';
|
|
9
|
+
import { InsertInto } from './query/Insert.ts';
|
|
10
|
+
import type { SelectBase, WithSelection, WithoutSelection } from './query/Select.ts';
|
|
11
|
+
import { UpdateTable } from './query/Update.ts';
|
|
12
|
+
declare class BuilderBase<Meta extends QueryMeta> {
|
|
13
|
+
readonly [internalData]: QueryData<Meta>;
|
|
14
|
+
constructor(data: QueryData<Meta>);
|
|
15
|
+
createTable<Definition extends TableDefinition>(table: Table<Definition>): Create<Meta>;
|
|
16
|
+
dropTable(table: HasTable): Drop<Meta>;
|
|
17
|
+
select(): WithoutSelection<Meta>;
|
|
18
|
+
select<Input extends SelectionInput>(selection: Input): WithSelection<Input, Meta>;
|
|
19
|
+
selectDistinct(): WithoutSelection<Meta>;
|
|
20
|
+
selectDistinct<Input extends SelectionInput>(selection: Input): WithSelection<Input, Meta>;
|
|
21
|
+
selectDistinctOn(this: Builder<IsPostgres>, columns: Array<HasSql>): WithoutSelection<Meta>;
|
|
22
|
+
selectDistinctOn<Input extends SelectionInput>(this: Builder<IsPostgres>, columns: Array<HasSql>, selection: Input): WithSelection<Input, Meta>;
|
|
23
|
+
update<Definition extends TableDefinition>(table: Table<Definition>): UpdateTable<Definition, Meta>;
|
|
24
|
+
insert<Definition extends TableDefinition>(into: Table<Definition>): InsertInto<Definition, Meta>;
|
|
25
|
+
delete(from: HasTable): DeleteFrom<Meta>;
|
|
26
|
+
}
|
|
27
|
+
export type CTE<Input = unknown> = Input & HasTarget & HasQuery;
|
|
28
|
+
export declare class Builder<Meta extends QueryMeta> extends BuilderBase<Meta> {
|
|
29
|
+
$with(cteName: string): {
|
|
30
|
+
as<Input extends SelectionInput>(query: SelectBase<Input, Meta>): CTE<Input>;
|
|
31
|
+
};
|
|
32
|
+
with(...cte: Array<CTE>): BuilderBase<Meta>;
|
|
33
|
+
createTable<Definition extends TableDefinition>(table: Table<Definition>): Create<Meta>;
|
|
34
|
+
dropTable(table: HasTable): Drop<Meta>;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { HasColumn, HasSql } from './Internal.ts';
|
|
2
|
+
import { internalColumn } from './Internal.ts';
|
|
3
|
+
import type { Sql } from './Sql.ts';
|
|
4
|
+
import type { Field, FieldData } from './expr/Field.ts';
|
|
5
|
+
import { type Input } from './expr/Input.ts';
|
|
6
|
+
export declare class ColumnData {
|
|
7
|
+
type: Sql;
|
|
8
|
+
name?: string;
|
|
9
|
+
json?: boolean;
|
|
10
|
+
primary?: boolean;
|
|
11
|
+
notNull?: boolean;
|
|
12
|
+
isUnique?: boolean;
|
|
13
|
+
autoIncrement?: boolean;
|
|
14
|
+
defaultValue?(): HasSql;
|
|
15
|
+
references?(): FieldData;
|
|
16
|
+
onUpdate?: HasSql;
|
|
17
|
+
onDelete?: HasSql;
|
|
18
|
+
mapFromDriverValue?(value: unknown): unknown;
|
|
19
|
+
mapToDriverValue?(value: unknown): unknown;
|
|
20
|
+
}
|
|
21
|
+
export declare class Column<Value = unknown> implements HasColumn {
|
|
22
|
+
readonly [internalColumn]: ColumnData;
|
|
23
|
+
constructor(data: ColumnData);
|
|
24
|
+
notNull(): RequiredColumn<NonNullable<Value>>;
|
|
25
|
+
default(value: Input<NonNullable<Value>> | (() => Input<NonNullable<Value>>)): Column<NonNullable<Value>>;
|
|
26
|
+
primaryKey(): Column<NonNullable<Value>>;
|
|
27
|
+
unique(name?: string): Column<Value>;
|
|
28
|
+
references(foreignField: Field | (() => Field)): Column<Value>;
|
|
29
|
+
}
|
|
30
|
+
export declare class JsonColumn<Value = unknown> extends Column<Value> {
|
|
31
|
+
private brand;
|
|
32
|
+
constructor(data: ColumnData);
|
|
33
|
+
}
|
|
34
|
+
declare const required: unique symbol;
|
|
35
|
+
export interface RequiredColumn<Value = unknown> extends Column<Value> {
|
|
36
|
+
[required]: true;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { internalConstraint, internalData, type HasConstraint, type HasData } from './Internal.ts';
|
|
2
|
+
import type { Field, FieldData } from './expr/Field.ts';
|
|
3
|
+
export interface UniqueConstraintData {
|
|
4
|
+
fields: Array<FieldData>;
|
|
5
|
+
nullsNotDistinct?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class UniqueConstraint<TableName extends string = string> implements HasData<UniqueConstraintData>, HasConstraint {
|
|
8
|
+
private brand;
|
|
9
|
+
[internalData]: UniqueConstraintData;
|
|
10
|
+
constructor(data: UniqueConstraintData);
|
|
11
|
+
on<TableName extends string>(...columns: Array<Field<unknown, TableName>>): UniqueConstraint<TableName>;
|
|
12
|
+
nullsNotDistinct(): UniqueConstraint<string>;
|
|
13
|
+
get [internalConstraint](): import("./Sql.ts").Sql<unknown>;
|
|
14
|
+
}
|
|
15
|
+
export declare function unique(): UniqueConstraint<string>;
|
|
16
|
+
export interface PrimaryKeyConstraintData {
|
|
17
|
+
fields: Array<FieldData>;
|
|
18
|
+
}
|
|
19
|
+
export declare class PrimaryKeyConstraint<TableName extends string = string> implements HasData<PrimaryKeyConstraintData>, HasConstraint {
|
|
20
|
+
data: PrimaryKeyConstraintData;
|
|
21
|
+
private brand;
|
|
22
|
+
[internalData]: PrimaryKeyConstraintData;
|
|
23
|
+
constructor(data: PrimaryKeyConstraintData);
|
|
24
|
+
get [internalConstraint](): import("./Sql.ts").Sql<unknown>;
|
|
25
|
+
}
|
|
26
|
+
export declare function primaryKey<TableName extends string = string>(...fields: Array<Field<unknown, TableName>>): PrimaryKeyConstraint<TableName>;
|
|
27
|
+
export interface ForeignKeyConstraintData {
|
|
28
|
+
fields: Array<FieldData>;
|
|
29
|
+
references: Array<FieldData>;
|
|
30
|
+
}
|
|
31
|
+
export declare class ForeignKeyConstraint<TableName extends string = string> implements HasData<ForeignKeyConstraintData>, HasConstraint {
|
|
32
|
+
private brand;
|
|
33
|
+
[internalData]: ForeignKeyConstraintData;
|
|
34
|
+
constructor(data: ForeignKeyConstraintData);
|
|
35
|
+
references<ForeignTable extends string>(...fields: Array<Field<unknown, ForeignTable>>): ForeignKeyConstraint<TableName>;
|
|
36
|
+
get [internalConstraint](): import("./Sql.ts").Sql<unknown>;
|
|
37
|
+
}
|
|
38
|
+
export declare function foreignKey<TableName extends string = string>(...fields: Array<Field<unknown, TableName>>): ForeignKeyConstraint<TableName>;
|
|
39
|
+
export type Constraint = UniqueConstraint | PrimaryKeyConstraint | ForeignKeyConstraint;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Builder } from './Builder.ts';
|
|
2
|
+
import type { Dialect } from './Dialect.ts';
|
|
3
|
+
import type { Driver } from './Driver.ts';
|
|
4
|
+
import { internalResolver, type HasResolver } from './Internal.ts';
|
|
5
|
+
import type { Async, Either, QueryDialect, QueryMeta, Sync } from './MetaData.ts';
|
|
6
|
+
import { Resolver } from './Resolver.ts';
|
|
7
|
+
export declare class Database<Meta extends QueryMeta = Either> extends Builder<Meta> implements HasResolver<Meta> {
|
|
8
|
+
#private;
|
|
9
|
+
readonly [internalResolver]: Resolver<Meta>;
|
|
10
|
+
constructor(driver: Driver, dialect: Dialect, transactionDepth?: number);
|
|
11
|
+
close(this: Database<Async>): Promise<void>;
|
|
12
|
+
close(this: Database<Sync>): void;
|
|
13
|
+
[Symbol.dispose](this: Database<Sync>): void;
|
|
14
|
+
[Symbol.asyncDispose](this: Database<Async>): Promise<void>;
|
|
15
|
+
transaction<T>(this: Database<Sync>, run: (tx: Transaction<Meta>) => T, options?: TransactionOptions[Meta['dialect']]): T;
|
|
16
|
+
transaction<T>(this: Database<Async>, run: (tx: Transaction<Meta>) => Promise<T>, options?: TransactionOptions[Meta['dialect']]): Promise<T>;
|
|
17
|
+
transaction<T>(run: (tx: Transaction<Meta>) => T | Promise<T>, options?: TransactionOptions[Meta['dialect']]): T | Promise<T>;
|
|
18
|
+
}
|
|
19
|
+
export interface TransactionOptions {
|
|
20
|
+
universal: never;
|
|
21
|
+
sqlite: {
|
|
22
|
+
behavior?: 'deferred' | 'immediate' | 'exclusive';
|
|
23
|
+
};
|
|
24
|
+
postgres: {
|
|
25
|
+
isolationLevel?: 'read uncommitted' | 'read committed' | 'repeatable read' | 'serializable';
|
|
26
|
+
accessMode?: 'read only' | 'read write';
|
|
27
|
+
deferrable?: boolean;
|
|
28
|
+
};
|
|
29
|
+
mysql: {
|
|
30
|
+
isolationLevel?: 'read uncommitted' | 'read committed' | 'repeatable read' | 'serializable';
|
|
31
|
+
accessMode?: 'read only' | 'read write';
|
|
32
|
+
withConsistentSnapshot?: boolean;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export declare class Rollback extends Error {
|
|
36
|
+
}
|
|
37
|
+
export declare class Transaction<Meta extends QueryMeta> extends Database<Meta> {
|
|
38
|
+
rollback(): never;
|
|
39
|
+
}
|
|
40
|
+
export declare class SyncDatabase<Dialect extends QueryDialect> extends Database<Sync<Dialect>> {
|
|
41
|
+
}
|
|
42
|
+
export declare class AsyncDatabase<Dialect extends QueryDialect> extends Database<Async<Dialect>> {
|
|
43
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Emitter } from './Emitter.ts';
|
|
2
|
+
import { type HasQuery, type HasSql } from './Internal.ts';
|
|
3
|
+
export declare function dialect(createEmitter: {
|
|
4
|
+
new (): Emitter;
|
|
5
|
+
}): (input: HasSql | HasQuery) => Emitter;
|
|
6
|
+
export type Dialect = ReturnType<typeof dialect>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type Driver = SyncDriver | AsyncDriver;
|
|
2
|
+
export type Statement = SyncStatement | AsyncStatement;
|
|
3
|
+
export interface SyncDriver {
|
|
4
|
+
close(): void;
|
|
5
|
+
exec(query: string): void;
|
|
6
|
+
prepare(query: string, name?: string): SyncStatement;
|
|
7
|
+
transaction<T>(run: (inner: SyncDriver) => T, options: unknown, depth: number): T;
|
|
8
|
+
}
|
|
9
|
+
export interface SyncStatement {
|
|
10
|
+
all(params: Array<unknown>): Array<object>;
|
|
11
|
+
run(params: Array<unknown>): void;
|
|
12
|
+
get(params: Array<unknown>): object | null;
|
|
13
|
+
values(params: Array<unknown>): Array<Array<unknown>>;
|
|
14
|
+
free(): void;
|
|
15
|
+
}
|
|
16
|
+
export interface AsyncDriver {
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
exec(query: string): Promise<void>;
|
|
19
|
+
prepare(query: string, name?: string): AsyncStatement;
|
|
20
|
+
transaction<T>(run: (inner: AsyncDriver) => Promise<T>, options: unknown, depth: number): Promise<T>;
|
|
21
|
+
}
|
|
22
|
+
export interface AsyncStatement {
|
|
23
|
+
all(params: Array<unknown>): Promise<Array<object>>;
|
|
24
|
+
run(params: Array<unknown>): Promise<void>;
|
|
25
|
+
get(params: Array<unknown>): Promise<object | null>;
|
|
26
|
+
values(params: Array<unknown>): Promise<Array<Array<unknown>>>;
|
|
27
|
+
free(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ColumnData } from './Column.ts';
|
|
2
|
+
import { type HasQuery, type HasTarget } from './Internal.ts';
|
|
3
|
+
import { type Param } from './Param.ts';
|
|
4
|
+
import type { FieldData } from './expr/Field.ts';
|
|
5
|
+
import type { Create } from './query/CreateTable.ts';
|
|
6
|
+
import type { Delete } from './query/Delete.ts';
|
|
7
|
+
import type { Drop } from './query/DropTable.ts';
|
|
8
|
+
import type { Insert } from './query/Insert.ts';
|
|
9
|
+
import type { Select } from './query/Select.ts';
|
|
10
|
+
import type { Union } from './query/Union.ts';
|
|
11
|
+
import type { Update } from './query/Update.ts';
|
|
12
|
+
export declare abstract class Emitter {
|
|
13
|
+
sql: string;
|
|
14
|
+
params: Array<Param>;
|
|
15
|
+
bind(inputs?: Record<string, unknown>): Array<unknown>;
|
|
16
|
+
abstract emitIdentifier(value: string): void;
|
|
17
|
+
abstract emitValue(value: unknown): void;
|
|
18
|
+
abstract emitInline(value: unknown): void;
|
|
19
|
+
abstract emitJsonPath(value: Array<number | string>): void;
|
|
20
|
+
abstract emitPlaceholder(value: string): void;
|
|
21
|
+
abstract emitDefaultValue(): void;
|
|
22
|
+
emitUnsafe(value: string): void;
|
|
23
|
+
emitField(field: FieldData): void;
|
|
24
|
+
emitCreateTable(create: Create): void;
|
|
25
|
+
emitDrop(drop: Drop): void;
|
|
26
|
+
emitColumn(column: ColumnData): void;
|
|
27
|
+
emitReferences(fields: Array<FieldData>): void;
|
|
28
|
+
emitDelete(deleteOp: Delete<unknown>): void;
|
|
29
|
+
emitInsert(insert: Insert<unknown>): void;
|
|
30
|
+
emitSelect(select: Select<unknown>): void;
|
|
31
|
+
emitUnion(union: Union<unknown>): void;
|
|
32
|
+
emitUpdate(update: Update<unknown>): void;
|
|
33
|
+
abstract emitIdColumn(): void;
|
|
34
|
+
emitWith(cte: Array<HasQuery & HasTarget>): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { internalData, type HasData, type HasSql } from './Internal.ts';
|
|
2
|
+
import type { Field, FieldData } from './expr/Field.ts';
|
|
3
|
+
export interface IndexData {
|
|
4
|
+
fields: Array<FieldData>;
|
|
5
|
+
unique?: boolean;
|
|
6
|
+
concurrently?: boolean;
|
|
7
|
+
only?: boolean;
|
|
8
|
+
using?: HasSql;
|
|
9
|
+
order?: 'asc' | 'desc';
|
|
10
|
+
nulls?: 'first' | 'last';
|
|
11
|
+
where?: HasSql;
|
|
12
|
+
}
|
|
13
|
+
export declare class Index<TableName extends string = string> implements HasData<IndexData> {
|
|
14
|
+
private brand;
|
|
15
|
+
[internalData]: IndexData;
|
|
16
|
+
constructor(data: IndexData);
|
|
17
|
+
on<TableName extends string>(...columns: Array<Field<unknown, TableName>>): Index<TableName>;
|
|
18
|
+
concurrently(): Index<string>;
|
|
19
|
+
only(): Index<string>;
|
|
20
|
+
using<Sql>(using: HasSql<Sql>): Index<string>;
|
|
21
|
+
asc(): Index<string>;
|
|
22
|
+
desc(): Index<string>;
|
|
23
|
+
nullsFirst(): Index<string>;
|
|
24
|
+
nullsLast(): Index<string>;
|
|
25
|
+
where(where: HasSql<boolean>): Index<string>;
|
|
26
|
+
}
|
|
27
|
+
export declare function index(): Index<string>;
|
|
28
|
+
export declare function uniqueIndex(): Index<string>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ColumnData } from './Column.ts';
|
|
2
|
+
import type { QueryMeta } from './MetaData.ts';
|
|
3
|
+
import type { Resolver } from './Resolver.ts';
|
|
4
|
+
import type { Selection } from './Selection.ts';
|
|
5
|
+
import type { Sql } from './Sql.ts';
|
|
6
|
+
import type { TableApi, TableDefinition } from './Table.ts';
|
|
7
|
+
import type { FieldData } from './expr/Field.ts';
|
|
8
|
+
export declare const internalData: unique symbol;
|
|
9
|
+
export declare const internalSql: unique symbol;
|
|
10
|
+
export declare const internalSelection: unique symbol;
|
|
11
|
+
export declare const internalTarget: unique symbol;
|
|
12
|
+
export declare const internalQuery: unique symbol;
|
|
13
|
+
export declare const internalTable: unique symbol;
|
|
14
|
+
export declare const internalColumn: unique symbol;
|
|
15
|
+
export declare const internalField: unique symbol;
|
|
16
|
+
export declare const internalResolver: unique symbol;
|
|
17
|
+
export declare const internalConstraint: unique symbol;
|
|
18
|
+
export declare class HasData<Data> {
|
|
19
|
+
get [internalData](): Data;
|
|
20
|
+
}
|
|
21
|
+
export declare class HasSql<Value = unknown> {
|
|
22
|
+
get [internalSql](): Sql<Value>;
|
|
23
|
+
}
|
|
24
|
+
export declare class HasSelection {
|
|
25
|
+
get [internalSelection](): Selection;
|
|
26
|
+
}
|
|
27
|
+
export declare class HasTarget {
|
|
28
|
+
get [internalTarget](): Sql;
|
|
29
|
+
}
|
|
30
|
+
export declare class HasQuery {
|
|
31
|
+
get [internalQuery](): Sql;
|
|
32
|
+
}
|
|
33
|
+
export declare class HasTable<Definition extends TableDefinition = TableDefinition, Name extends string = string> {
|
|
34
|
+
get [internalTable](): TableApi<Definition, Name>;
|
|
35
|
+
}
|
|
36
|
+
export declare class HasColumn {
|
|
37
|
+
get [internalColumn](): ColumnData;
|
|
38
|
+
}
|
|
39
|
+
export declare class HasField {
|
|
40
|
+
get [internalField](): FieldData;
|
|
41
|
+
}
|
|
42
|
+
export declare class HasResolver<Meta extends QueryMeta = QueryMeta> {
|
|
43
|
+
get [internalResolver](): Resolver<Meta>;
|
|
44
|
+
}
|
|
45
|
+
export declare class HasConstraint {
|
|
46
|
+
get [internalConstraint](): Sql;
|
|
47
|
+
}
|
|
48
|
+
export declare const hasData: <Data>(obj: object) => obj is HasData<Data>;
|
|
49
|
+
export declare const getData: <Data>(obj: HasData<Data>) => Data;
|
|
50
|
+
export declare const hasSql: <Value>(obj: object) => obj is HasSql<Value>;
|
|
51
|
+
export declare const getSql: <Value>(obj: HasSql<Value>) => Sql<Value>;
|
|
52
|
+
export declare const hasSelection: (obj: object) => obj is HasSelection;
|
|
53
|
+
export declare const getSelection: (obj: HasSelection) => Selection;
|
|
54
|
+
export declare const hasTarget: (obj: object) => obj is HasTarget;
|
|
55
|
+
export declare const getTarget: (obj: HasTarget) => Sql<unknown>;
|
|
56
|
+
export declare const hasQuery: (obj: object) => obj is HasQuery;
|
|
57
|
+
export declare const getQuery: (obj: HasQuery) => Sql<unknown>;
|
|
58
|
+
export declare const hasTable: (obj: object) => obj is HasTable<TableDefinition, string>;
|
|
59
|
+
export declare const getTable: (obj: HasTable) => TableApi<TableDefinition, string>;
|
|
60
|
+
export declare const hasColumn: (obj: object) => obj is HasColumn;
|
|
61
|
+
export declare const getColumn: (obj: HasColumn) => ColumnData;
|
|
62
|
+
export declare const hasField: (obj: object) => obj is HasField;
|
|
63
|
+
export declare const getField: (obj: HasField) => FieldData;
|
|
64
|
+
export declare const hasResolver: <Meta extends QueryMeta>(obj: object) => obj is HasResolver<Meta>;
|
|
65
|
+
export declare const getResolver: <Meta extends QueryMeta>(obj: HasResolver<Meta>) => Resolver<Meta>;
|
|
66
|
+
export declare const hasConstraint: (obj: object) => obj is HasConstraint;
|
|
67
|
+
export declare const getConstraint: (obj: HasConstraint) => Sql<unknown>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type QueryMode = 'sync' | 'async' | undefined;
|
|
2
|
+
export type QueryDialect = 'universal' | 'sqlite' | 'mysql' | 'postgres';
|
|
3
|
+
export interface QueryMeta {
|
|
4
|
+
mode: QueryMode;
|
|
5
|
+
dialect: QueryDialect;
|
|
6
|
+
}
|
|
7
|
+
export interface Sync<Dialect extends QueryDialect = QueryDialect> extends QueryMeta {
|
|
8
|
+
mode: 'sync';
|
|
9
|
+
dialect: Dialect;
|
|
10
|
+
}
|
|
11
|
+
export interface Async<Dialect extends QueryDialect = QueryDialect> extends QueryMeta {
|
|
12
|
+
mode: 'async';
|
|
13
|
+
dialect: Dialect;
|
|
14
|
+
}
|
|
15
|
+
export interface IsPostgres extends QueryMeta {
|
|
16
|
+
dialect: 'postgres';
|
|
17
|
+
}
|
|
18
|
+
export interface IsMysql extends QueryMeta {
|
|
19
|
+
dialect: 'mysql';
|
|
20
|
+
}
|
|
21
|
+
export interface IsSqlite extends QueryMeta {
|
|
22
|
+
dialect: 'sqlite';
|
|
23
|
+
}
|
|
24
|
+
export interface Either extends QueryMeta {
|
|
25
|
+
mode: 'sync' | 'async';
|
|
26
|
+
dialect: QueryDialect;
|
|
27
|
+
}
|