kysely 0.11.1 → 0.12.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/README.md +1 -1
- package/dist/cjs/dialect/mysql/mysql-query-compiler.d.ts +0 -2
- package/dist/cjs/dialect/mysql/mysql-query-compiler.js +0 -6
- package/dist/cjs/dialect/postgres/postgres-query-compiler.d.ts +3 -0
- package/dist/cjs/dialect/postgres/postgres-query-compiler.js +9 -1
- package/dist/cjs/dialect/sqlite/sqlite-adapter.js +6 -2
- package/dist/cjs/dialect/sqlite/sqlite-driver.js +7 -7
- package/dist/cjs/dialect/sqlite/sqlite-query-compiler.d.ts +2 -2
- package/dist/cjs/dialect/sqlite/sqlite-query-compiler.js +6 -6
- package/dist/cjs/driver/runtime-driver.js +1 -1
- package/dist/cjs/dynamic/dynamic-reference-builder.d.ts +1 -0
- package/dist/cjs/dynamic/dynamic-reference-builder.js +9 -1
- package/dist/cjs/dynamic/dynamic.d.ts +6 -7
- package/dist/cjs/dynamic/dynamic.js +6 -7
- package/dist/cjs/index.d.ts +51 -33
- package/dist/cjs/index.js +48 -30
- package/dist/cjs/kysely.d.ts +39 -15
- package/dist/cjs/kysely.js +32 -9
- package/dist/cjs/migration/migration.d.ts +2 -2
- package/dist/cjs/operation-node/alias-node.d.ts +1 -1
- package/dist/cjs/operation-node/create-table-node.d.ts +6 -2
- package/dist/cjs/operation-node/create-table-node.js +6 -6
- package/dist/cjs/operation-node/create-view-node.d.ts +1 -0
- package/dist/cjs/operation-node/insert-query-node.d.ts +4 -4
- package/dist/cjs/operation-node/operation-node-transformer.d.ts +2 -0
- package/dist/cjs/operation-node/operation-node-transformer.js +11 -1
- package/dist/cjs/operation-node/operation-node-utils.d.ts +1 -1
- package/dist/cjs/operation-node/operation-node-visitor.d.ts +2 -0
- package/dist/cjs/operation-node/operation-node-visitor.js +1 -0
- package/dist/cjs/operation-node/operation-node.d.ts +1 -1
- package/dist/cjs/operation-node/query-node.d.ts +0 -2
- package/dist/cjs/operation-node/query-node.js +0 -10
- package/dist/cjs/operation-node/values-node.d.ts +15 -0
- package/dist/cjs/operation-node/values-node.js +18 -0
- package/dist/cjs/parser/complex-expression-parser.d.ts +9 -0
- package/dist/cjs/parser/complex-expression-parser.js +25 -0
- package/dist/cjs/parser/filter-parser.d.ts +13 -3
- package/dist/cjs/parser/filter-parser.js +56 -62
- package/dist/cjs/parser/insert-values-parser.d.ts +7 -10
- package/dist/cjs/parser/insert-values-parser.js +31 -39
- package/dist/cjs/parser/order-by-parser.d.ts +1 -1
- package/dist/cjs/parser/parse-context.d.ts +8 -8
- package/dist/cjs/parser/parse-context.js +10 -10
- package/dist/cjs/parser/reference-parser.d.ts +8 -7
- package/dist/cjs/parser/reference-parser.js +8 -17
- package/dist/cjs/parser/returning-parser.d.ts +1 -5
- package/dist/cjs/parser/select-parser.d.ts +12 -14
- package/dist/cjs/parser/select-parser.js +5 -9
- package/dist/cjs/parser/table-parser.d.ts +9 -11
- package/dist/cjs/parser/table-parser.js +2 -8
- package/dist/cjs/parser/union-parser.d.ts +2 -2
- package/dist/cjs/parser/union-parser.js +1 -6
- package/dist/cjs/parser/update-set-parser.d.ts +2 -8
- package/dist/cjs/parser/update-set-parser.js +6 -26
- package/dist/cjs/parser/value-parser.d.ts +9 -6
- package/dist/cjs/parser/value-parser.js +7 -30
- package/dist/cjs/parser/with-parser.d.ts +6 -3
- package/dist/cjs/plugin/immediate-value.ts/immediate-value-plugin.js +2 -2
- package/dist/cjs/query-builder/delete-query-builder.d.ts +102 -0
- package/dist/cjs/query-builder/delete-query-builder.js +185 -0
- package/dist/cjs/query-builder/expression-builder.d.ts +8 -6
- package/dist/cjs/query-builder/expression-builder.js +3 -3
- package/dist/cjs/query-builder/function-builder.d.ts +2 -1
- package/dist/cjs/query-builder/function-builder.js +2 -1
- package/dist/cjs/query-builder/having-interface.d.ts +49 -0
- package/dist/cjs/query-builder/having-interface.js +2 -0
- package/dist/cjs/query-builder/insert-query-builder.d.ts +439 -0
- package/dist/cjs/query-builder/insert-query-builder.js +256 -0
- package/dist/cjs/query-builder/insert-result.d.ts +3 -2
- package/dist/cjs/query-builder/insert-result.js +3 -2
- package/dist/cjs/query-builder/join-builder.d.ts +22 -20
- package/dist/cjs/query-builder/join-builder.js +12 -12
- package/dist/cjs/query-builder/join-interface.d.ts +133 -0
- package/dist/cjs/query-builder/join-interface.js +2 -0
- package/dist/cjs/query-builder/no-result-error.d.ts +9 -0
- package/dist/cjs/query-builder/no-result-error.js +14 -0
- package/dist/cjs/query-builder/returning-interface.d.ts +73 -0
- package/dist/cjs/query-builder/returning-interface.js +2 -0
- package/dist/cjs/query-builder/select-query-builder.d.ts +711 -0
- package/dist/cjs/query-builder/select-query-builder.js +571 -0
- package/dist/cjs/query-builder/update-query-builder.d.ts +190 -0
- package/dist/cjs/query-builder/update-query-builder.js +279 -0
- package/dist/cjs/query-builder/where-interface.d.ts +381 -0
- package/dist/cjs/query-builder/where-interface.js +2 -0
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +2 -0
- package/dist/cjs/query-compiler/default-query-compiler.js +22 -5
- package/dist/cjs/query-creator.d.ts +42 -40
- package/dist/cjs/query-creator.js +33 -28
- package/dist/cjs/query-executor/query-executor.d.ts +1 -1
- package/dist/cjs/query-executor/query-executor.js +1 -1
- package/dist/cjs/raw-builder/raw-builder.d.ts +2 -0
- package/dist/cjs/raw-builder/raw-builder.js +6 -0
- package/dist/cjs/schema/alter-table-builder.d.ts +2 -2
- package/dist/cjs/schema/column-definition-builder.d.ts +27 -20
- package/dist/cjs/schema/create-index-builder.d.ts +2 -1
- package/dist/cjs/schema/create-index-builder.js +2 -1
- package/dist/cjs/schema/create-table-builder.d.ts +26 -9
- package/dist/cjs/schema/create-table-builder.js +42 -9
- package/dist/cjs/schema/create-view-builder.d.ts +17 -3
- package/dist/cjs/schema/create-view-builder.js +25 -16
- package/dist/cjs/schema/schema.d.ts +18 -11
- package/dist/cjs/schema/schema.js +18 -11
- package/dist/cjs/util/dynamic-import.js +1 -1
- package/dist/cjs/util/log.d.ts +11 -8
- package/dist/cjs/util/log.js +25 -12
- package/dist/cjs/util/type-utils.d.ts +7 -7
- package/dist/esm/dialect/mysql/mysql-query-compiler.d.ts +0 -2
- package/dist/esm/dialect/mysql/mysql-query-compiler.js +0 -6
- package/dist/esm/dialect/postgres/postgres-query-compiler.d.ts +3 -0
- package/dist/esm/dialect/postgres/postgres-query-compiler.js +9 -1
- package/dist/esm/dialect/sqlite/sqlite-adapter.js +6 -2
- package/dist/esm/dialect/sqlite/sqlite-driver.js +7 -7
- package/dist/esm/dialect/sqlite/sqlite-query-compiler.d.ts +2 -2
- package/dist/esm/dialect/sqlite/sqlite-query-compiler.js +6 -6
- package/dist/esm/driver/runtime-driver.js +1 -1
- package/dist/esm/dynamic/dynamic-reference-builder.d.ts +1 -0
- package/dist/esm/dynamic/dynamic-reference-builder.js +7 -0
- package/dist/esm/dynamic/dynamic.d.ts +6 -7
- package/dist/esm/dynamic/dynamic.js +6 -7
- package/dist/esm/index.d.ts +51 -33
- package/dist/esm/index.js +48 -30
- package/dist/esm/kysely.d.ts +39 -15
- package/dist/esm/kysely.js +32 -9
- package/dist/esm/migration/migration.d.ts +2 -2
- package/dist/esm/operation-node/alias-node.d.ts +1 -1
- package/dist/esm/operation-node/create-table-node.d.ts +6 -2
- package/dist/esm/operation-node/create-table-node.js +6 -6
- package/dist/esm/operation-node/create-view-node.d.ts +1 -0
- package/dist/esm/operation-node/insert-query-node.d.ts +4 -4
- package/dist/esm/operation-node/operation-node-transformer.d.ts +2 -0
- package/dist/esm/operation-node/operation-node-transformer.js +11 -1
- package/dist/esm/operation-node/operation-node-utils.d.ts +1 -1
- package/dist/esm/operation-node/operation-node-visitor.d.ts +2 -0
- package/dist/esm/operation-node/operation-node-visitor.js +1 -0
- package/dist/esm/operation-node/operation-node.d.ts +1 -1
- package/dist/esm/operation-node/query-node.d.ts +0 -2
- package/dist/esm/operation-node/query-node.js +0 -10
- package/dist/esm/operation-node/values-node.d.ts +15 -0
- package/dist/esm/operation-node/values-node.js +15 -0
- package/dist/esm/parser/complex-expression-parser.d.ts +9 -0
- package/dist/esm/parser/complex-expression-parser.js +20 -0
- package/dist/esm/parser/filter-parser.d.ts +13 -3
- package/dist/esm/parser/filter-parser.js +55 -62
- package/dist/esm/parser/insert-values-parser.d.ts +7 -10
- package/dist/esm/parser/insert-values-parser.js +31 -38
- package/dist/esm/parser/order-by-parser.d.ts +1 -1
- package/dist/esm/parser/parse-context.d.ts +8 -8
- package/dist/esm/parser/parse-context.js +10 -10
- package/dist/esm/parser/reference-parser.d.ts +8 -7
- package/dist/esm/parser/reference-parser.js +9 -18
- package/dist/esm/parser/returning-parser.d.ts +1 -5
- package/dist/esm/parser/select-parser.d.ts +12 -14
- package/dist/esm/parser/select-parser.js +6 -10
- package/dist/esm/parser/table-parser.d.ts +9 -11
- package/dist/esm/parser/table-parser.js +3 -9
- package/dist/esm/parser/union-parser.d.ts +2 -2
- package/dist/esm/parser/union-parser.js +1 -6
- package/dist/esm/parser/update-set-parser.d.ts +2 -8
- package/dist/esm/parser/update-set-parser.js +5 -24
- package/dist/esm/parser/value-parser.d.ts +9 -6
- package/dist/esm/parser/value-parser.js +8 -31
- package/dist/esm/parser/with-parser.d.ts +6 -3
- package/dist/esm/plugin/immediate-value.ts/immediate-value-plugin.js +2 -2
- package/dist/esm/query-builder/delete-query-builder.d.ts +102 -0
- package/dist/esm/query-builder/delete-query-builder.js +181 -0
- package/dist/esm/query-builder/expression-builder.d.ts +8 -6
- package/dist/esm/query-builder/expression-builder.js +3 -3
- package/dist/esm/query-builder/function-builder.d.ts +2 -1
- package/dist/esm/query-builder/function-builder.js +2 -1
- package/dist/esm/query-builder/having-interface.d.ts +49 -0
- package/dist/esm/query-builder/having-interface.js +1 -0
- package/dist/esm/query-builder/insert-query-builder.d.ts +439 -0
- package/dist/esm/query-builder/insert-query-builder.js +252 -0
- package/dist/esm/query-builder/insert-result.d.ts +3 -2
- package/dist/esm/query-builder/insert-result.js +3 -2
- package/dist/esm/query-builder/join-builder.d.ts +22 -20
- package/dist/esm/query-builder/join-builder.js +12 -12
- package/dist/esm/query-builder/join-interface.d.ts +133 -0
- package/dist/esm/query-builder/join-interface.js +1 -0
- package/dist/esm/query-builder/no-result-error.d.ts +9 -0
- package/dist/esm/query-builder/no-result-error.js +10 -0
- package/dist/esm/query-builder/returning-interface.d.ts +73 -0
- package/dist/esm/query-builder/returning-interface.js +1 -0
- package/dist/esm/query-builder/select-query-builder.d.ts +711 -0
- package/dist/esm/query-builder/select-query-builder.js +566 -0
- package/dist/esm/query-builder/update-query-builder.d.ts +190 -0
- package/dist/esm/query-builder/update-query-builder.js +275 -0
- package/dist/esm/query-builder/where-interface.d.ts +381 -0
- package/dist/esm/query-builder/where-interface.js +1 -0
- package/dist/esm/query-compiler/default-query-compiler.d.ts +2 -0
- package/dist/esm/query-compiler/default-query-compiler.js +22 -5
- package/dist/esm/query-creator.d.ts +42 -40
- package/dist/esm/query-creator.js +33 -28
- package/dist/esm/query-executor/query-executor.d.ts +1 -1
- package/dist/esm/query-executor/query-executor.js +1 -1
- package/dist/esm/raw-builder/raw-builder.d.ts +2 -0
- package/dist/esm/raw-builder/raw-builder.js +6 -0
- package/dist/esm/schema/alter-table-builder.d.ts +2 -2
- package/dist/esm/schema/column-definition-builder.d.ts +27 -20
- package/dist/esm/schema/create-index-builder.d.ts +2 -1
- package/dist/esm/schema/create-index-builder.js +2 -1
- package/dist/esm/schema/create-table-builder.d.ts +26 -9
- package/dist/esm/schema/create-table-builder.js +43 -10
- package/dist/esm/schema/create-view-builder.d.ts +17 -3
- package/dist/esm/schema/create-view-builder.js +25 -16
- package/dist/esm/schema/schema.d.ts +18 -11
- package/dist/esm/schema/schema.js +18 -11
- package/dist/esm/util/dynamic-import.js +1 -1
- package/dist/esm/util/log.d.ts +11 -8
- package/dist/esm/util/log.js +25 -12
- package/dist/esm/util/type-utils.d.ts +7 -7
- package/package.json +3 -3
- package/dist/cjs/query-builder/query-builder.d.ts +0 -1707
- package/dist/cjs/query-builder/query-builder.js +0 -1067
- package/dist/esm/query-builder/query-builder.d.ts +0 -1707
- package/dist/esm/query-builder/query-builder.js +0 -1061
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';
|
|
2
2
|
export class MysqlQueryCompiler extends DefaultQueryCompiler {
|
|
3
|
-
visitReturning() {
|
|
4
|
-
// Do nothing.
|
|
5
|
-
}
|
|
6
|
-
getSql() {
|
|
7
|
-
return super.getSql().trimEnd();
|
|
8
|
-
}
|
|
9
3
|
getCurrentParameterPlaceholder() {
|
|
10
4
|
return '?';
|
|
11
5
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';
|
|
2
2
|
export declare class PostgresQueryCompiler extends DefaultQueryCompiler {
|
|
3
|
+
protected getCurrentParameterPlaceholder(): string;
|
|
4
|
+
protected getLeftIdentifierWrapper(): string;
|
|
5
|
+
protected getRightIdentifierWrapper(): string;
|
|
3
6
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';
|
|
2
|
-
// The default query compiler is for PostgreSQL.
|
|
3
2
|
export class PostgresQueryCompiler extends DefaultQueryCompiler {
|
|
3
|
+
getCurrentParameterPlaceholder() {
|
|
4
|
+
return '$' + this.numParameters;
|
|
5
|
+
}
|
|
6
|
+
getLeftIdentifierWrapper() {
|
|
7
|
+
return '"';
|
|
8
|
+
}
|
|
9
|
+
getRightIdentifierWrapper() {
|
|
10
|
+
return '"';
|
|
11
|
+
}
|
|
4
12
|
}
|
|
@@ -6,9 +6,13 @@ export class SqliteAdapter {
|
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
8
|
async acquireMigrationLock() {
|
|
9
|
-
//
|
|
9
|
+
// SQLite only has one connection that's reserved by the migration system
|
|
10
|
+
// for the whole time between acquireMigrationLock and releaseMigrationLock.
|
|
11
|
+
// We don't need to do anything here.
|
|
10
12
|
}
|
|
11
13
|
async releaseMigrationLock() {
|
|
12
|
-
//
|
|
14
|
+
// SQLite only has one connection that's reserved by the migration system
|
|
15
|
+
// for the whole time between acquireMigrationLock and releaseMigrationLock.
|
|
16
|
+
// We don't need to do anything here.
|
|
13
17
|
}
|
|
14
18
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CompiledQuery } from '../../query-compiler/compiled-query.js';
|
|
2
2
|
import { importFunction } from '../../util/dynamic-import.js';
|
|
3
|
+
import { isBoolean, isFunction, isNumber } from '../../util/object-utils.js';
|
|
3
4
|
export class SqliteDriver {
|
|
4
5
|
#config;
|
|
5
6
|
#connectionMutex = new ConnectionMutex();
|
|
@@ -16,16 +17,16 @@ export class SqliteDriver {
|
|
|
16
17
|
// into javascript. You can check the built javascript code.
|
|
17
18
|
const DatabaseConstructor = await importBetterSqlite3Database();
|
|
18
19
|
const options = {};
|
|
19
|
-
if (
|
|
20
|
+
if (isBoolean(this.#config.readonly)) {
|
|
20
21
|
options.readonly = this.#config.readonly;
|
|
21
22
|
}
|
|
22
|
-
if (
|
|
23
|
+
if (isBoolean(this.#config.fileMustExist)) {
|
|
23
24
|
options.fileMustExist = this.#config.fileMustExist;
|
|
24
25
|
}
|
|
25
|
-
if (
|
|
26
|
+
if (isNumber(this.#config.timeout)) {
|
|
26
27
|
options.timeout = this.#config.timeout;
|
|
27
28
|
}
|
|
28
|
-
if (
|
|
29
|
+
if (isFunction(this.#config.verbose)) {
|
|
29
30
|
options.verbose = this.#config.verbose;
|
|
30
31
|
}
|
|
31
32
|
this.#db = new DatabaseConstructor(this.#config.databasePath, options);
|
|
@@ -35,8 +36,8 @@ export class SqliteDriver {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
async acquireConnection() {
|
|
38
|
-
//
|
|
39
|
-
//
|
|
39
|
+
// SQLite only has one single connection. We use a mutex here to wait
|
|
40
|
+
// until the single connection has been released.
|
|
40
41
|
await this.#connectionMutex.lock();
|
|
41
42
|
return this.#connection;
|
|
42
43
|
}
|
|
@@ -61,7 +62,6 @@ async function importBetterSqlite3Database() {
|
|
|
61
62
|
return await importFunction('better-sqlite3');
|
|
62
63
|
}
|
|
63
64
|
catch (error) {
|
|
64
|
-
console.error(error);
|
|
65
65
|
throw new Error('SQLite client not installed. Please run `npm install better-sqlite3`');
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';
|
|
2
2
|
export declare class SqliteQueryCompiler extends DefaultQueryCompiler {
|
|
3
|
-
protected visitReturning(): void;
|
|
4
|
-
protected getSql(): string;
|
|
5
3
|
protected getCurrentParameterPlaceholder(): string;
|
|
4
|
+
protected getLeftIdentifierWrapper(): string;
|
|
5
|
+
protected getRightIdentifierWrapper(): string;
|
|
6
6
|
protected getAutoIncrement(): string;
|
|
7
7
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';
|
|
2
2
|
export class SqliteQueryCompiler extends DefaultQueryCompiler {
|
|
3
|
-
visitReturning() {
|
|
4
|
-
// Do nothing.
|
|
5
|
-
}
|
|
6
|
-
getSql() {
|
|
7
|
-
return super.getSql().trimEnd();
|
|
8
|
-
}
|
|
9
3
|
getCurrentParameterPlaceholder() {
|
|
10
4
|
return '?';
|
|
11
5
|
}
|
|
6
|
+
getLeftIdentifierWrapper() {
|
|
7
|
+
return '"';
|
|
8
|
+
}
|
|
9
|
+
getRightIdentifierWrapper() {
|
|
10
|
+
return '"';
|
|
11
|
+
}
|
|
12
12
|
getAutoIncrement() {
|
|
13
13
|
return 'autoincrement';
|
|
14
14
|
}
|
|
@@ -16,3 +16,4 @@ export declare class DynamicReferenceBuilder<R extends string = never> implement
|
|
|
16
16
|
constructor(reference: string);
|
|
17
17
|
toOperationNode(): ReferenceNode | ColumnNode;
|
|
18
18
|
}
|
|
19
|
+
export declare function isDynamicReferenceBuilder(obj: unknown): obj is DynamicReferenceBuilder<any>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { isOperationNodeSource, } from '../operation-node/operation-node-source.js';
|
|
1
2
|
import { parseStringReference } from '../parser/reference-parser.js';
|
|
3
|
+
import { isObject, isString } from '../util/object-utils.js';
|
|
2
4
|
export class DynamicReferenceBuilder {
|
|
3
5
|
#dynamicReference;
|
|
4
6
|
get dynamicReference() {
|
|
@@ -22,3 +24,8 @@ export class DynamicReferenceBuilder {
|
|
|
22
24
|
return parseStringReference(this.#dynamicReference);
|
|
23
25
|
}
|
|
24
26
|
}
|
|
27
|
+
export function isDynamicReferenceBuilder(obj) {
|
|
28
|
+
return (isObject(obj) &&
|
|
29
|
+
isOperationNodeSource(obj) &&
|
|
30
|
+
isString(obj.dynamicReference));
|
|
31
|
+
}
|
|
@@ -20,7 +20,8 @@ export declare class DynamicModule {
|
|
|
20
20
|
* `ref` to other methods as well. If the types allow you to pass a `ref`
|
|
21
21
|
* value to some place, it should work.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* ### Examples
|
|
24
|
+
*
|
|
24
25
|
* Filter by a column not know at compile time:
|
|
25
26
|
*
|
|
26
27
|
* ```ts
|
|
@@ -38,7 +39,6 @@ export declare class DynamicModule {
|
|
|
38
39
|
* someQuery('person.last_name', 'Aniston')
|
|
39
40
|
* ```
|
|
40
41
|
*
|
|
41
|
-
* @example
|
|
42
42
|
* Order by a column not know at compile time:
|
|
43
43
|
*
|
|
44
44
|
* ```ts
|
|
@@ -55,7 +55,6 @@ export declare class DynamicModule {
|
|
|
55
55
|
* someQuery('fn')
|
|
56
56
|
* ```
|
|
57
57
|
*
|
|
58
|
-
* @example
|
|
59
58
|
* In this example we add selections dynamically:
|
|
60
59
|
*
|
|
61
60
|
* ```ts
|
|
@@ -66,7 +65,7 @@ export declare class DynamicModule {
|
|
|
66
65
|
*
|
|
67
66
|
* // A type that lists all possible values `columnFromUserInput` can have.
|
|
68
67
|
* // You can use `keyof Person` if any column of an interface is allowed.
|
|
69
|
-
* type PossibleColumns = 'last_name' |
|
|
68
|
+
* type PossibleColumns = 'last_name' | 'first_name' | 'birth_date'
|
|
70
69
|
*
|
|
71
70
|
* const [person] = await db.selectFrom('person')
|
|
72
71
|
* .select([
|
|
@@ -78,9 +77,9 @@ export declare class DynamicModule {
|
|
|
78
77
|
* // The resulting type contains all `PossibleColumns` as optional fields
|
|
79
78
|
* // because we cannot know which field was actually selected before
|
|
80
79
|
* // running the code.
|
|
81
|
-
* const lastName: string |
|
|
82
|
-
* const firstName: string |
|
|
83
|
-
* const birthDate: string |
|
|
80
|
+
* const lastName: string | undefined = person.last_name
|
|
81
|
+
* const firstName: string | undefined = person.first_name
|
|
82
|
+
* const birthDate: string | undefined = person.birth_date
|
|
84
83
|
*
|
|
85
84
|
* // The result type also contains the compile time selection `id`.
|
|
86
85
|
* person.id
|
|
@@ -20,7 +20,8 @@ export class DynamicModule {
|
|
|
20
20
|
* `ref` to other methods as well. If the types allow you to pass a `ref`
|
|
21
21
|
* value to some place, it should work.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* ### Examples
|
|
24
|
+
*
|
|
24
25
|
* Filter by a column not know at compile time:
|
|
25
26
|
*
|
|
26
27
|
* ```ts
|
|
@@ -38,7 +39,6 @@ export class DynamicModule {
|
|
|
38
39
|
* someQuery('person.last_name', 'Aniston')
|
|
39
40
|
* ```
|
|
40
41
|
*
|
|
41
|
-
* @example
|
|
42
42
|
* Order by a column not know at compile time:
|
|
43
43
|
*
|
|
44
44
|
* ```ts
|
|
@@ -55,7 +55,6 @@ export class DynamicModule {
|
|
|
55
55
|
* someQuery('fn')
|
|
56
56
|
* ```
|
|
57
57
|
*
|
|
58
|
-
* @example
|
|
59
58
|
* In this example we add selections dynamically:
|
|
60
59
|
*
|
|
61
60
|
* ```ts
|
|
@@ -66,7 +65,7 @@ export class DynamicModule {
|
|
|
66
65
|
*
|
|
67
66
|
* // A type that lists all possible values `columnFromUserInput` can have.
|
|
68
67
|
* // You can use `keyof Person` if any column of an interface is allowed.
|
|
69
|
-
* type PossibleColumns = 'last_name' |
|
|
68
|
+
* type PossibleColumns = 'last_name' | 'first_name' | 'birth_date'
|
|
70
69
|
*
|
|
71
70
|
* const [person] = await db.selectFrom('person')
|
|
72
71
|
* .select([
|
|
@@ -78,9 +77,9 @@ export class DynamicModule {
|
|
|
78
77
|
* // The resulting type contains all `PossibleColumns` as optional fields
|
|
79
78
|
* // because we cannot know which field was actually selected before
|
|
80
79
|
* // running the code.
|
|
81
|
-
* const lastName: string |
|
|
82
|
-
* const firstName: string |
|
|
83
|
-
* const birthDate: string |
|
|
80
|
+
* const lastName: string | undefined = person.last_name
|
|
81
|
+
* const firstName: string | undefined = person.first_name
|
|
82
|
+
* const birthDate: string | undefined = person.birth_date
|
|
84
83
|
*
|
|
85
84
|
* // The result type also contains the compile time selection `id`.
|
|
86
85
|
* person.id
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
export * from './kysely.js';
|
|
2
2
|
export * from './query-creator.js';
|
|
3
|
-
export * from './query-builder/
|
|
3
|
+
export * from './query-builder/where-interface.js';
|
|
4
|
+
export * from './query-builder/join-interface.js';
|
|
5
|
+
export * from './query-builder/returning-interface.js';
|
|
6
|
+
export * from './query-builder/having-interface.js';
|
|
7
|
+
export * from './query-builder/select-query-builder.js';
|
|
8
|
+
export * from './query-builder/insert-query-builder.js';
|
|
9
|
+
export * from './query-builder/update-query-builder.js';
|
|
10
|
+
export * from './query-builder/delete-query-builder.js';
|
|
11
|
+
export * from './query-builder/no-result-error.js';
|
|
4
12
|
export * from './query-builder/join-builder.js';
|
|
5
13
|
export * from './query-builder/expression-builder.js';
|
|
14
|
+
export * from './query-builder/function-builder.js';
|
|
6
15
|
export * from './query-builder/insert-result.js';
|
|
7
16
|
export * from './query-builder/delete-result.js';
|
|
8
17
|
export * from './query-builder/update-result.js';
|
|
@@ -51,35 +60,8 @@ export * from './migration/migration.js';
|
|
|
51
60
|
export * from './dialect/dialect.js';
|
|
52
61
|
export * from './dialect/dialect-adapter.js';
|
|
53
62
|
export * from './dialect/dialect-adapter-base.js';
|
|
54
|
-
export * from './operation-node/operation-node-transformer.js';
|
|
55
|
-
export * from './operation-node/operation-node-visitor.js';
|
|
56
63
|
export * from './plugin/kysely-plugin.js';
|
|
57
64
|
export * from './plugin/camel-case/camel-case-plugin.js';
|
|
58
|
-
export * from './operation-node/operation-node-transformer.js';
|
|
59
|
-
export * from './operation-node/operation-node-visitor.js';
|
|
60
|
-
export * from './operation-node/operator-node.js';
|
|
61
|
-
export * from './operation-node/or-node.js';
|
|
62
|
-
export * from './operation-node/order-by-item-node.js';
|
|
63
|
-
export * from './operation-node/order-by-node.js';
|
|
64
|
-
export * from './operation-node/parens-node.js';
|
|
65
|
-
export * from './operation-node/primary-constraint-node.js';
|
|
66
|
-
export * from './operation-node/primitive-value-list-node.js';
|
|
67
|
-
export * from './operation-node/query-node.js';
|
|
68
|
-
export * from './operation-node/raw-node.js';
|
|
69
|
-
export * from './operation-node/reference-node.js';
|
|
70
|
-
export * from './operation-node/references-node.js';
|
|
71
|
-
export * from './operation-node/rename-column-node.js';
|
|
72
|
-
export * from './operation-node/returning-node.js';
|
|
73
|
-
export * from './operation-node/select-all-node.js';
|
|
74
|
-
export * from './operation-node/select-query-node.js';
|
|
75
|
-
export * from './operation-node/selection-node.js';
|
|
76
|
-
export * from './operation-node/table-node.js';
|
|
77
|
-
export * from './operation-node/unique-constraint-node.js';
|
|
78
|
-
export * from './operation-node/update-query-node.js';
|
|
79
|
-
export * from './operation-node/value-list-node.js';
|
|
80
|
-
export * from './operation-node/value-node.js';
|
|
81
|
-
export * from './operation-node/where-node.js';
|
|
82
|
-
export * from './operation-node/with-node.js';
|
|
83
65
|
export * from './operation-node/add-column-node.js';
|
|
84
66
|
export * from './operation-node/add-constraint-node.js';
|
|
85
67
|
export * from './operation-node/alias-node.js';
|
|
@@ -95,16 +77,20 @@ export * from './operation-node/constraint-node.js';
|
|
|
95
77
|
export * from './operation-node/create-index-node.js';
|
|
96
78
|
export * from './operation-node/create-schema-node.js';
|
|
97
79
|
export * from './operation-node/create-table-node.js';
|
|
80
|
+
export * from './operation-node/create-view-node.js';
|
|
98
81
|
export * from './operation-node/data-type-node.js';
|
|
82
|
+
export * from './operation-node/default-value-node.js';
|
|
99
83
|
export * from './operation-node/delete-query-node.js';
|
|
100
84
|
export * from './operation-node/drop-column-node.js';
|
|
101
85
|
export * from './operation-node/drop-constraint-node.js';
|
|
102
86
|
export * from './operation-node/drop-index-node.js';
|
|
103
87
|
export * from './operation-node/drop-schema-node.js';
|
|
104
88
|
export * from './operation-node/drop-table-node.js';
|
|
89
|
+
export * from './operation-node/drop-view-node.js';
|
|
105
90
|
export * from './operation-node/filter-node.js';
|
|
106
91
|
export * from './operation-node/foreign-key-constraint-node.js';
|
|
107
92
|
export * from './operation-node/from-node.js';
|
|
93
|
+
export * from './operation-node/generated-always-as-node.js';
|
|
108
94
|
export * from './operation-node/group-by-item-node.js';
|
|
109
95
|
export * from './operation-node/group-by-node.js';
|
|
110
96
|
export * from './operation-node/having-node.js';
|
|
@@ -113,19 +99,51 @@ export * from './operation-node/insert-query-node.js';
|
|
|
113
99
|
export * from './operation-node/join-node.js';
|
|
114
100
|
export * from './operation-node/limit-node.js';
|
|
115
101
|
export * from './operation-node/list-node.js';
|
|
102
|
+
export * from './operation-node/modify-column-node.js';
|
|
116
103
|
export * from './operation-node/offset-node.js';
|
|
117
|
-
export * from './operation-node
|
|
118
|
-
export * from './operation-node/
|
|
104
|
+
export * from './operation-node/on-conflict-node.js';
|
|
105
|
+
export * from './operation-node/on-duplicate-key-node.js';
|
|
106
|
+
export * from './operation-node/on-node.js';
|
|
119
107
|
export * from './operation-node/operation-node-source.js';
|
|
108
|
+
export * from './operation-node/operation-node-transformer.js';
|
|
109
|
+
export * from './operation-node/operation-node-utils.js';
|
|
110
|
+
export * from './operation-node/operation-node-visitor.js';
|
|
111
|
+
export * from './operation-node/operation-node.js';
|
|
112
|
+
export * from './operation-node/operator-node.js';
|
|
113
|
+
export * from './operation-node/or-node.js';
|
|
114
|
+
export * from './operation-node/order-by-item-node.js';
|
|
120
115
|
export * from './operation-node/order-by-node.js';
|
|
116
|
+
export * from './operation-node/parens-node.js';
|
|
117
|
+
export * from './operation-node/primary-constraint-node.js';
|
|
118
|
+
export * from './operation-node/primitive-value-list-node.js';
|
|
119
|
+
export * from './operation-node/query-node.js';
|
|
120
|
+
export * from './operation-node/raw-node.js';
|
|
121
|
+
export * from './operation-node/reference-node.js';
|
|
122
|
+
export * from './operation-node/references-node.js';
|
|
123
|
+
export * from './operation-node/rename-column-node.js';
|
|
124
|
+
export * from './operation-node/returning-node.js';
|
|
125
|
+
export * from './operation-node/select-all-node.js';
|
|
126
|
+
export * from './operation-node/select-query-node.js';
|
|
127
|
+
export * from './operation-node/select-query-node.js';
|
|
128
|
+
export * from './operation-node/selection-node.js';
|
|
129
|
+
export * from './operation-node/table-node.js';
|
|
130
|
+
export * from './operation-node/union-node.js';
|
|
131
|
+
export * from './operation-node/unique-constraint-node.js';
|
|
132
|
+
export * from './operation-node/update-query-node.js';
|
|
133
|
+
export * from './operation-node/value-list-node.js';
|
|
134
|
+
export * from './operation-node/value-node.js';
|
|
135
|
+
export * from './operation-node/values-node.js';
|
|
136
|
+
export * from './operation-node/where-node.js';
|
|
137
|
+
export * from './operation-node/with-node.js';
|
|
121
138
|
export * from './introspection/database-introspector.js';
|
|
122
139
|
export * from './util/compilable.js';
|
|
123
|
-
export
|
|
140
|
+
export * from './util/log.js';
|
|
141
|
+
export { AnyColumn, UnknownRow, AnySelectQueryBuilder, } from './util/type-utils.js';
|
|
124
142
|
export { SelectExpression, SelectExpressionOrList, } from './parser/select-parser.js';
|
|
125
143
|
export { ReferenceExpression, ReferenceExpressionOrList, } from './parser/reference-parser.js';
|
|
126
144
|
export { ValueExpression, ValueExpressionOrList, } from './parser/value-parser.js';
|
|
127
|
-
export { ExistsExpression, FilterOperator } from './parser/filter-parser.js';
|
|
128
|
-
export { TableExpression } from './parser/table-parser.js';
|
|
145
|
+
export { FilterValueExpression, FilterValueExpressionOrList, ExistsExpression, FilterOperator, } from './parser/filter-parser.js';
|
|
146
|
+
export { TableExpression, TableExpressionOrList, } from './parser/table-parser.js';
|
|
129
147
|
export { JoinReferenceExpression, JoinCallbackExpression, } from './parser/join-parser.js';
|
|
130
148
|
export { InsertObject } from './parser/insert-values-parser.js';
|
|
131
149
|
export { MutationObject } from './parser/update-set-parser.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
export * from './kysely.js';
|
|
2
2
|
export * from './query-creator.js';
|
|
3
|
-
export * from './query-builder/
|
|
3
|
+
export * from './query-builder/where-interface.js';
|
|
4
|
+
export * from './query-builder/join-interface.js';
|
|
5
|
+
export * from './query-builder/returning-interface.js';
|
|
6
|
+
export * from './query-builder/having-interface.js';
|
|
7
|
+
export * from './query-builder/select-query-builder.js';
|
|
8
|
+
export * from './query-builder/insert-query-builder.js';
|
|
9
|
+
export * from './query-builder/update-query-builder.js';
|
|
10
|
+
export * from './query-builder/delete-query-builder.js';
|
|
11
|
+
export * from './query-builder/no-result-error.js';
|
|
4
12
|
export * from './query-builder/join-builder.js';
|
|
5
13
|
export * from './query-builder/expression-builder.js';
|
|
14
|
+
export * from './query-builder/function-builder.js';
|
|
6
15
|
export * from './query-builder/insert-result.js';
|
|
7
16
|
export * from './query-builder/delete-result.js';
|
|
8
17
|
export * from './query-builder/update-result.js';
|
|
@@ -51,35 +60,8 @@ export * from './migration/migration.js';
|
|
|
51
60
|
export * from './dialect/dialect.js';
|
|
52
61
|
export * from './dialect/dialect-adapter.js';
|
|
53
62
|
export * from './dialect/dialect-adapter-base.js';
|
|
54
|
-
export * from './operation-node/operation-node-transformer.js';
|
|
55
|
-
export * from './operation-node/operation-node-visitor.js';
|
|
56
63
|
export * from './plugin/kysely-plugin.js';
|
|
57
64
|
export * from './plugin/camel-case/camel-case-plugin.js';
|
|
58
|
-
export * from './operation-node/operation-node-transformer.js';
|
|
59
|
-
export * from './operation-node/operation-node-visitor.js';
|
|
60
|
-
export * from './operation-node/operator-node.js';
|
|
61
|
-
export * from './operation-node/or-node.js';
|
|
62
|
-
export * from './operation-node/order-by-item-node.js';
|
|
63
|
-
export * from './operation-node/order-by-node.js';
|
|
64
|
-
export * from './operation-node/parens-node.js';
|
|
65
|
-
export * from './operation-node/primary-constraint-node.js';
|
|
66
|
-
export * from './operation-node/primitive-value-list-node.js';
|
|
67
|
-
export * from './operation-node/query-node.js';
|
|
68
|
-
export * from './operation-node/raw-node.js';
|
|
69
|
-
export * from './operation-node/reference-node.js';
|
|
70
|
-
export * from './operation-node/references-node.js';
|
|
71
|
-
export * from './operation-node/rename-column-node.js';
|
|
72
|
-
export * from './operation-node/returning-node.js';
|
|
73
|
-
export * from './operation-node/select-all-node.js';
|
|
74
|
-
export * from './operation-node/select-query-node.js';
|
|
75
|
-
export * from './operation-node/selection-node.js';
|
|
76
|
-
export * from './operation-node/table-node.js';
|
|
77
|
-
export * from './operation-node/unique-constraint-node.js';
|
|
78
|
-
export * from './operation-node/update-query-node.js';
|
|
79
|
-
export * from './operation-node/value-list-node.js';
|
|
80
|
-
export * from './operation-node/value-node.js';
|
|
81
|
-
export * from './operation-node/where-node.js';
|
|
82
|
-
export * from './operation-node/with-node.js';
|
|
83
65
|
export * from './operation-node/add-column-node.js';
|
|
84
66
|
export * from './operation-node/add-constraint-node.js';
|
|
85
67
|
export * from './operation-node/alias-node.js';
|
|
@@ -95,16 +77,20 @@ export * from './operation-node/constraint-node.js';
|
|
|
95
77
|
export * from './operation-node/create-index-node.js';
|
|
96
78
|
export * from './operation-node/create-schema-node.js';
|
|
97
79
|
export * from './operation-node/create-table-node.js';
|
|
80
|
+
export * from './operation-node/create-view-node.js';
|
|
98
81
|
export * from './operation-node/data-type-node.js';
|
|
82
|
+
export * from './operation-node/default-value-node.js';
|
|
99
83
|
export * from './operation-node/delete-query-node.js';
|
|
100
84
|
export * from './operation-node/drop-column-node.js';
|
|
101
85
|
export * from './operation-node/drop-constraint-node.js';
|
|
102
86
|
export * from './operation-node/drop-index-node.js';
|
|
103
87
|
export * from './operation-node/drop-schema-node.js';
|
|
104
88
|
export * from './operation-node/drop-table-node.js';
|
|
89
|
+
export * from './operation-node/drop-view-node.js';
|
|
105
90
|
export * from './operation-node/filter-node.js';
|
|
106
91
|
export * from './operation-node/foreign-key-constraint-node.js';
|
|
107
92
|
export * from './operation-node/from-node.js';
|
|
93
|
+
export * from './operation-node/generated-always-as-node.js';
|
|
108
94
|
export * from './operation-node/group-by-item-node.js';
|
|
109
95
|
export * from './operation-node/group-by-node.js';
|
|
110
96
|
export * from './operation-node/having-node.js';
|
|
@@ -113,10 +99,42 @@ export * from './operation-node/insert-query-node.js';
|
|
|
113
99
|
export * from './operation-node/join-node.js';
|
|
114
100
|
export * from './operation-node/limit-node.js';
|
|
115
101
|
export * from './operation-node/list-node.js';
|
|
102
|
+
export * from './operation-node/modify-column-node.js';
|
|
116
103
|
export * from './operation-node/offset-node.js';
|
|
117
|
-
export * from './operation-node
|
|
118
|
-
export * from './operation-node/
|
|
104
|
+
export * from './operation-node/on-conflict-node.js';
|
|
105
|
+
export * from './operation-node/on-duplicate-key-node.js';
|
|
106
|
+
export * from './operation-node/on-node.js';
|
|
119
107
|
export * from './operation-node/operation-node-source.js';
|
|
108
|
+
export * from './operation-node/operation-node-transformer.js';
|
|
109
|
+
export * from './operation-node/operation-node-utils.js';
|
|
110
|
+
export * from './operation-node/operation-node-visitor.js';
|
|
111
|
+
export * from './operation-node/operation-node.js';
|
|
112
|
+
export * from './operation-node/operator-node.js';
|
|
113
|
+
export * from './operation-node/or-node.js';
|
|
114
|
+
export * from './operation-node/order-by-item-node.js';
|
|
120
115
|
export * from './operation-node/order-by-node.js';
|
|
116
|
+
export * from './operation-node/parens-node.js';
|
|
117
|
+
export * from './operation-node/primary-constraint-node.js';
|
|
118
|
+
export * from './operation-node/primitive-value-list-node.js';
|
|
119
|
+
export * from './operation-node/query-node.js';
|
|
120
|
+
export * from './operation-node/raw-node.js';
|
|
121
|
+
export * from './operation-node/reference-node.js';
|
|
122
|
+
export * from './operation-node/references-node.js';
|
|
123
|
+
export * from './operation-node/rename-column-node.js';
|
|
124
|
+
export * from './operation-node/returning-node.js';
|
|
125
|
+
export * from './operation-node/select-all-node.js';
|
|
126
|
+
export * from './operation-node/select-query-node.js';
|
|
127
|
+
export * from './operation-node/select-query-node.js';
|
|
128
|
+
export * from './operation-node/selection-node.js';
|
|
129
|
+
export * from './operation-node/table-node.js';
|
|
130
|
+
export * from './operation-node/union-node.js';
|
|
131
|
+
export * from './operation-node/unique-constraint-node.js';
|
|
132
|
+
export * from './operation-node/update-query-node.js';
|
|
133
|
+
export * from './operation-node/value-list-node.js';
|
|
134
|
+
export * from './operation-node/value-node.js';
|
|
135
|
+
export * from './operation-node/values-node.js';
|
|
136
|
+
export * from './operation-node/where-node.js';
|
|
137
|
+
export * from './operation-node/with-node.js';
|
|
121
138
|
export * from './introspection/database-introspector.js';
|
|
122
139
|
export * from './util/compilable.js';
|
|
140
|
+
export * from './util/log.js';
|
package/dist/esm/kysely.d.ts
CHANGED
|
@@ -10,14 +10,15 @@ import { DatabaseIntrospector } from './introspection/database-introspector.js';
|
|
|
10
10
|
import { Driver, IsolationLevel } from './driver/driver.js';
|
|
11
11
|
import { ParseContext } from './parser/parse-context.js';
|
|
12
12
|
import { FunctionBuilder } from './query-builder/function-builder.js';
|
|
13
|
-
import {
|
|
13
|
+
import { LogConfig } from './util/log.js';
|
|
14
14
|
/**
|
|
15
15
|
* The main Kysely class.
|
|
16
16
|
*
|
|
17
17
|
* You should create one instance of `Kysely` per database using the {@link Kysely}
|
|
18
18
|
* constructor. Each `Kysely` instance maintains it's own connection pool.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
20
|
+
* ### Examples
|
|
21
|
+
*
|
|
21
22
|
* This example assumes your database has tables `person` and `pet`:
|
|
22
23
|
*
|
|
23
24
|
* ```ts
|
|
@@ -31,7 +32,7 @@ import { LogLevel } from './util/log.js';
|
|
|
31
32
|
* id: number
|
|
32
33
|
* owner_id: number
|
|
33
34
|
* name: string
|
|
34
|
-
* species 'cat' |
|
|
35
|
+
* species 'cat' | 'dog'
|
|
35
36
|
* }
|
|
36
37
|
*
|
|
37
38
|
* interface Database {
|
|
@@ -78,10 +79,11 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
78
79
|
* A value to be used in place of columns that are generated in the database
|
|
79
80
|
* when inserting rows.
|
|
80
81
|
*
|
|
81
|
-
*
|
|
82
|
+
* ### Examples
|
|
83
|
+
*
|
|
82
84
|
* In this example the `Person` table has non-null properties `id` and `created_at`
|
|
83
85
|
* which are both automatically genereted by the database. Since their types are
|
|
84
|
-
* `number` and `string` respectively instead of `number |
|
|
86
|
+
* `number` and `string` respectively instead of `number | null` and `string | null`
|
|
85
87
|
* the `values` method requires you to give a value for them. the `generated`
|
|
86
88
|
* placeholder can be used in these cases.
|
|
87
89
|
*
|
|
@@ -136,12 +138,13 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
136
138
|
* transaction. If the function throws, the transaction is rolled back. Otherwise
|
|
137
139
|
* the transaction is committed.
|
|
138
140
|
*
|
|
139
|
-
* The callback function passed to the {@link TransactionBuilder.execute |
|
|
141
|
+
* The callback function passed to the {@link TransactionBuilder.execute | execute}
|
|
140
142
|
* method gets the transaction object as its only argument. The transaction is
|
|
141
143
|
* of type {@link Transaction} which inherits {@link Kysely}. Any query
|
|
142
144
|
* started through the transaction object is executed inside the transaction.
|
|
143
145
|
*
|
|
144
|
-
*
|
|
146
|
+
* ### Examples
|
|
147
|
+
*
|
|
145
148
|
* ```ts
|
|
146
149
|
* const catto = await db.transaction().execute(async (trx) => {
|
|
147
150
|
* const jennifer = await trx.insertInto('person')
|
|
@@ -167,8 +170,7 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
167
170
|
* })
|
|
168
171
|
* ```
|
|
169
172
|
*
|
|
170
|
-
*
|
|
171
|
-
* Setting the isolation level.
|
|
173
|
+
* Setting the isolation level:
|
|
172
174
|
*
|
|
173
175
|
* ```ts
|
|
174
176
|
* await db
|
|
@@ -183,7 +185,8 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
183
185
|
/**
|
|
184
186
|
* Provides a kysely instance bound to a single database connection.
|
|
185
187
|
*
|
|
186
|
-
*
|
|
188
|
+
* ### Examples
|
|
189
|
+
*
|
|
187
190
|
* ```ts
|
|
188
191
|
* await db
|
|
189
192
|
* .connection()
|
|
@@ -218,10 +221,15 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
218
221
|
get isTransaction(): boolean;
|
|
219
222
|
}
|
|
220
223
|
export declare class Transaction<DB> extends Kysely<DB> {
|
|
224
|
+
#private;
|
|
225
|
+
constructor(props: KyselyProps);
|
|
221
226
|
get isTransaction(): true;
|
|
222
227
|
get migration(): MigrationModule;
|
|
223
228
|
transaction(): TransactionBuilder<DB>;
|
|
229
|
+
connection(): ConnectionBuilder<DB>;
|
|
224
230
|
destroy(): Promise<void>;
|
|
231
|
+
withPlugin(plugin: KyselyPlugin): Transaction<DB>;
|
|
232
|
+
withoutPlugins(): Transaction<DB>;
|
|
225
233
|
}
|
|
226
234
|
export interface KyselyProps {
|
|
227
235
|
readonly config: KyselyConfig;
|
|
@@ -235,17 +243,33 @@ export interface KyselyConfig {
|
|
|
235
243
|
readonly dialect: Dialect;
|
|
236
244
|
readonly plugins?: KyselyPlugin[];
|
|
237
245
|
/**
|
|
238
|
-
* A list of log levels to log.
|
|
246
|
+
* A list of log levels to log or a custom logger function.
|
|
239
247
|
*
|
|
240
248
|
* Currently there's only two levels: `query` and `error`.
|
|
241
249
|
* This will be expanded based on user feedback later.
|
|
242
250
|
*
|
|
243
|
-
*
|
|
251
|
+
* ### Examples
|
|
244
252
|
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
253
|
+
* ```ts
|
|
254
|
+
* const db = new Kysely<Database>({
|
|
255
|
+
* dialect: new PostgresDialect(postgresConfig),
|
|
256
|
+
* log: ['query', 'error']
|
|
257
|
+
* })
|
|
258
|
+
* ```
|
|
259
|
+
*
|
|
260
|
+
* ```ts
|
|
261
|
+
* const db = new Kysely<Database>({
|
|
262
|
+
* dialect: new PostgresDialect(postgresConfig),
|
|
263
|
+
* log(event): void {
|
|
264
|
+
* if (event.level === 'query') {
|
|
265
|
+
* console.log(event.query.sql)
|
|
266
|
+
* console.log(event.query.parameters)
|
|
267
|
+
* }
|
|
268
|
+
* }
|
|
269
|
+
* })
|
|
270
|
+
* ```
|
|
247
271
|
*/
|
|
248
|
-
readonly log?:
|
|
272
|
+
readonly log?: LogConfig;
|
|
249
273
|
}
|
|
250
274
|
export declare class ConnectionBuilder<DB> {
|
|
251
275
|
#private;
|