kysely 0.10.1 → 0.11.3
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 +7 -3
- package/dist/cjs/dialect/dialect-adapter.d.ts +3 -2
- package/dist/cjs/dialect/mysql/mysql-adapter.js +1 -1
- package/dist/cjs/dialect/mysql/mysql-dialect.d.ts +3 -3
- package/dist/cjs/dialect/mysql/mysql-driver.js +25 -32
- 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-dialect.d.ts +2 -2
- package/dist/cjs/dialect/postgres/postgres-driver.js +8 -19
- 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.d.ts +7 -0
- package/dist/cjs/dialect/sqlite/sqlite-adapter.js +18 -0
- package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +64 -0
- package/dist/cjs/dialect/sqlite/sqlite-dialect.js +33 -0
- package/dist/cjs/dialect/sqlite/sqlite-driver.d.ts +14 -0
- package/dist/cjs/dialect/sqlite/sqlite-driver.js +116 -0
- package/dist/cjs/dialect/sqlite/sqlite-introspector.d.ts +7 -0
- package/dist/cjs/dialect/sqlite/sqlite-introspector.js +44 -0
- package/dist/cjs/dialect/sqlite/sqlite-query-compiler.d.ts +7 -0
- package/dist/cjs/dialect/sqlite/sqlite-query-compiler.js +19 -0
- package/dist/cjs/driver/database-connection.d.ts +2 -2
- package/dist/cjs/driver/runtime-driver.js +1 -1
- package/dist/cjs/index.d.ts +46 -30
- package/dist/cjs/index.js +45 -29
- package/dist/cjs/kysely.d.ts +28 -10
- package/dist/cjs/kysely.js +6 -4
- package/dist/cjs/migration/migration.d.ts +1 -1
- package/dist/cjs/migration/migration.js +3 -3
- package/dist/cjs/operation-node/alias-node.d.ts +1 -1
- package/dist/cjs/operation-node/create-view-node.d.ts +1 -0
- package/dist/cjs/operation-node/having-node.d.ts +4 -8
- package/dist/cjs/operation-node/having-node.js +3 -3
- package/dist/cjs/operation-node/join-node.d.ts +6 -9
- package/dist/cjs/operation-node/join-node.js +10 -7
- package/dist/cjs/operation-node/on-node.d.ts +14 -0
- package/dist/cjs/operation-node/on-node.js +28 -0
- package/dist/cjs/operation-node/operation-node-transformer.d.ts +2 -0
- package/dist/cjs/operation-node/operation-node-transformer.js +8 -0
- package/dist/cjs/operation-node/operation-node-utils.d.ts +1 -1
- package/dist/cjs/operation-node/operation-node-visitor.d.ts +3 -0
- package/dist/cjs/operation-node/operation-node-visitor.js +4 -0
- package/dist/cjs/operation-node/operation-node.d.ts +1 -1
- package/dist/cjs/operation-node/query-node.d.ts +3 -3
- package/dist/cjs/operation-node/select-query-node.d.ts +4 -4
- package/dist/cjs/operation-node/where-node.d.ts +4 -8
- package/dist/cjs/operation-node/where-node.js +3 -3
- package/dist/cjs/parser/filter-parser.d.ts +1 -0
- package/dist/cjs/parser/filter-parser.js +49 -52
- package/dist/cjs/parser/returning-parser.d.ts +4 -2
- package/dist/cjs/parser/select-parser.d.ts +2 -2
- package/dist/cjs/plugin/immediate-value.ts/immediate-value-plugin.d.ts +1 -1
- package/dist/cjs/query-builder/delete-result.d.ts +5 -0
- package/dist/cjs/query-builder/delete-result.js +13 -0
- package/dist/cjs/query-builder/expression-builder.d.ts +2 -2
- package/dist/cjs/query-builder/expression-builder.js +1 -1
- package/dist/cjs/query-builder/function-builder.d.ts +5 -5
- package/dist/cjs/query-builder/function-builder.js +3 -3
- package/dist/cjs/query-builder/insert-result.d.ts +27 -0
- package/dist/cjs/query-builder/insert-result.js +35 -0
- package/dist/cjs/query-builder/join-builder.d.ts +3 -0
- package/dist/cjs/query-builder/query-builder.d.ts +95 -81
- package/dist/cjs/query-builder/query-builder.js +38 -41
- package/dist/cjs/query-builder/update-result.d.ts +5 -0
- package/dist/cjs/query-builder/update-result.js +13 -0
- package/dist/cjs/query-compiler/compiled-query.d.ts +5 -0
- package/dist/cjs/query-compiler/compiled-query.js +12 -0
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +2 -0
- package/dist/cjs/query-compiler/default-query-compiler.js +24 -13
- package/dist/cjs/query-creator.d.ts +36 -26
- package/dist/cjs/query-creator.js +25 -17
- package/dist/cjs/schema/create-view-builder.d.ts +4 -0
- package/dist/cjs/schema/create-view-builder.js +11 -0
- package/dist/cjs/util/dynamic-import.d.ts +2 -0
- package/dist/cjs/util/dynamic-import.js +32 -0
- package/dist/cjs/util/log.d.ts +10 -8
- package/dist/cjs/util/log.js +29 -9
- package/dist/cjs/util/type-utils.d.ts +4 -15
- package/dist/esm/dialect/dialect-adapter.d.ts +3 -2
- package/dist/esm/dialect/mysql/mysql-adapter.js +1 -1
- package/dist/esm/dialect/mysql/mysql-dialect.d.ts +3 -3
- package/dist/esm/dialect/mysql/mysql-driver.js +26 -33
- 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-dialect.d.ts +2 -2
- package/dist/esm/dialect/postgres/postgres-driver.js +8 -19
- 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.d.ts +7 -0
- package/dist/esm/dialect/sqlite/sqlite-adapter.js +14 -0
- package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +64 -0
- package/dist/esm/dialect/sqlite/sqlite-dialect.js +29 -0
- package/dist/esm/dialect/sqlite/sqlite-driver.d.ts +14 -0
- package/dist/esm/dialect/sqlite/sqlite-driver.js +112 -0
- package/dist/esm/dialect/sqlite/sqlite-introspector.d.ts +7 -0
- package/dist/esm/dialect/sqlite/sqlite-introspector.js +40 -0
- package/dist/esm/dialect/sqlite/sqlite-query-compiler.d.ts +7 -0
- package/dist/esm/dialect/sqlite/sqlite-query-compiler.js +15 -0
- package/dist/esm/driver/database-connection.d.ts +2 -2
- package/dist/esm/driver/runtime-driver.js +1 -1
- package/dist/esm/index.d.ts +46 -30
- package/dist/esm/index.js +45 -29
- package/dist/esm/kysely.d.ts +28 -10
- package/dist/esm/kysely.js +6 -4
- package/dist/esm/migration/migration.d.ts +1 -1
- package/dist/esm/migration/migration.js +3 -3
- package/dist/esm/operation-node/alias-node.d.ts +1 -1
- package/dist/esm/operation-node/create-view-node.d.ts +1 -0
- package/dist/esm/operation-node/having-node.d.ts +4 -8
- package/dist/esm/operation-node/having-node.js +3 -3
- package/dist/esm/operation-node/join-node.d.ts +6 -9
- package/dist/esm/operation-node/join-node.js +10 -7
- package/dist/esm/operation-node/on-node.d.ts +14 -0
- package/dist/esm/operation-node/on-node.js +25 -0
- package/dist/esm/operation-node/operation-node-transformer.d.ts +2 -0
- package/dist/esm/operation-node/operation-node-transformer.js +8 -0
- package/dist/esm/operation-node/operation-node-utils.d.ts +1 -1
- package/dist/esm/operation-node/operation-node-visitor.d.ts +3 -0
- package/dist/esm/operation-node/operation-node-visitor.js +4 -0
- package/dist/esm/operation-node/operation-node.d.ts +1 -1
- package/dist/esm/operation-node/query-node.d.ts +3 -3
- package/dist/esm/operation-node/select-query-node.d.ts +4 -4
- package/dist/esm/operation-node/where-node.d.ts +4 -8
- package/dist/esm/operation-node/where-node.js +3 -3
- package/dist/esm/parser/filter-parser.d.ts +1 -0
- package/dist/esm/parser/filter-parser.js +48 -52
- package/dist/esm/parser/returning-parser.d.ts +4 -2
- package/dist/esm/parser/select-parser.d.ts +2 -2
- package/dist/esm/plugin/immediate-value.ts/immediate-value-plugin.d.ts +1 -1
- package/dist/esm/query-builder/delete-result.d.ts +5 -0
- package/dist/esm/query-builder/delete-result.js +9 -0
- package/dist/esm/query-builder/expression-builder.d.ts +2 -2
- package/dist/esm/query-builder/expression-builder.js +1 -1
- package/dist/esm/query-builder/function-builder.d.ts +5 -5
- package/dist/esm/query-builder/function-builder.js +3 -3
- package/dist/esm/query-builder/insert-result.d.ts +27 -0
- package/dist/esm/query-builder/insert-result.js +31 -0
- package/dist/esm/query-builder/join-builder.d.ts +3 -0
- package/dist/esm/query-builder/query-builder.d.ts +95 -81
- package/dist/esm/query-builder/query-builder.js +38 -41
- package/dist/esm/query-builder/update-result.d.ts +5 -0
- package/dist/esm/query-builder/update-result.js +9 -0
- package/dist/esm/query-compiler/compiled-query.d.ts +5 -0
- package/dist/esm/query-compiler/compiled-query.js +11 -1
- package/dist/esm/query-compiler/default-query-compiler.d.ts +2 -0
- package/dist/esm/query-compiler/default-query-compiler.js +24 -13
- package/dist/esm/query-creator.d.ts +36 -26
- package/dist/esm/query-creator.js +25 -17
- package/dist/esm/schema/create-view-builder.d.ts +4 -0
- package/dist/esm/schema/create-view-builder.js +11 -0
- package/dist/esm/util/dynamic-import.d.ts +2 -0
- package/dist/esm/util/dynamic-import.js +27 -0
- package/dist/esm/util/log.d.ts +10 -8
- package/dist/esm/util/log.js +30 -10
- package/dist/esm/util/type-utils.d.ts +4 -15
- package/package.json +3 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Driver } from '../../driver/driver.js';
|
|
2
|
+
import { Kysely } from '../../kysely.js';
|
|
3
|
+
import { QueryCompiler } from '../../query-compiler/query-compiler.js';
|
|
4
|
+
import { Dialect } from '../dialect.js';
|
|
5
|
+
import { DatabaseIntrospector } from '../../introspection/database-introspector.js';
|
|
6
|
+
import { DialectAdapter } from '../dialect-adapter.js';
|
|
7
|
+
import { DatabaseConnection } from '../../driver/database-connection.js';
|
|
8
|
+
/**
|
|
9
|
+
* SQLite dialect that uses the [better-sqlite3](https://github.com/JoshuaWise/better-sqlite3) library.
|
|
10
|
+
*
|
|
11
|
+
* The {@link SqliteDialectConfig | configuration} is used to construct an instance of
|
|
12
|
+
* [Database](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/api.md#new-databasepath-options)
|
|
13
|
+
* class. The configuration values are passed directly to the `Database` constructor.
|
|
14
|
+
*/
|
|
15
|
+
export declare class SqliteDialect implements Dialect {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(config: SqliteDialectConfig);
|
|
18
|
+
createDriver(): Driver;
|
|
19
|
+
createQueryCompiler(): QueryCompiler;
|
|
20
|
+
createAdapter(): DialectAdapter;
|
|
21
|
+
createIntrospector(db: Kysely<any>): DatabaseIntrospector;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Config for the SQLite dialect.
|
|
25
|
+
*
|
|
26
|
+
* This interface is equal to `better-sqlite3` library's `Databse` class's constructor parameters.
|
|
27
|
+
*
|
|
28
|
+
* https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/api.md#new-databasepath-options
|
|
29
|
+
*/
|
|
30
|
+
export interface SqliteDialectConfig {
|
|
31
|
+
/**
|
|
32
|
+
* The database file path.
|
|
33
|
+
*
|
|
34
|
+
* This is passed as the first argument for the [Database](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/api.md#new-databasepath-options)
|
|
35
|
+
* class constructor.
|
|
36
|
+
*/
|
|
37
|
+
databasePath: string;
|
|
38
|
+
/**
|
|
39
|
+
* Open the database connection in readonly mode (default: false)
|
|
40
|
+
*/
|
|
41
|
+
readonly?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* If the database does not exist, an Error will be thrown instead of creating a new file.
|
|
44
|
+
* This option is ignored for in-memory, temporary, or readonly database connections
|
|
45
|
+
* (default: false)
|
|
46
|
+
*/
|
|
47
|
+
fileMustExist?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The number of milliseconds to wait when executing queries on a locked database,
|
|
50
|
+
* before throwing a SQLITE_BUSY error (default: 5000)
|
|
51
|
+
*/
|
|
52
|
+
timeout?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Provide a function that gets called with every SQL string executed by the database connection
|
|
55
|
+
* (default: null)
|
|
56
|
+
*/
|
|
57
|
+
verbose?: (sql: string) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Called once when the first query is executed.
|
|
60
|
+
*
|
|
61
|
+
* This is a Kysely specific feature and does not come from the `better-sqlite3` module.
|
|
62
|
+
*/
|
|
63
|
+
onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SqliteDriver } from './sqlite-driver.js';
|
|
2
|
+
import { SqliteQueryCompiler } from './sqlite-query-compiler.js';
|
|
3
|
+
import { SqliteIntrospector } from './sqlite-introspector.js';
|
|
4
|
+
import { SqliteAdapter } from './sqlite-adapter.js';
|
|
5
|
+
/**
|
|
6
|
+
* SQLite dialect that uses the [better-sqlite3](https://github.com/JoshuaWise/better-sqlite3) library.
|
|
7
|
+
*
|
|
8
|
+
* The {@link SqliteDialectConfig | configuration} is used to construct an instance of
|
|
9
|
+
* [Database](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/api.md#new-databasepath-options)
|
|
10
|
+
* class. The configuration values are passed directly to the `Database` constructor.
|
|
11
|
+
*/
|
|
12
|
+
export class SqliteDialect {
|
|
13
|
+
#config;
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.#config = config;
|
|
16
|
+
}
|
|
17
|
+
createDriver() {
|
|
18
|
+
return new SqliteDriver(this.#config);
|
|
19
|
+
}
|
|
20
|
+
createQueryCompiler() {
|
|
21
|
+
return new SqliteQueryCompiler();
|
|
22
|
+
}
|
|
23
|
+
createAdapter() {
|
|
24
|
+
return new SqliteAdapter();
|
|
25
|
+
}
|
|
26
|
+
createIntrospector(db) {
|
|
27
|
+
return new SqliteIntrospector(db);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DatabaseConnection } from '../../driver/database-connection.js';
|
|
2
|
+
import { Driver } from '../../driver/driver.js';
|
|
3
|
+
import { SqliteDialectConfig } from './sqlite-dialect.js';
|
|
4
|
+
export declare class SqliteDriver implements Driver {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(config: SqliteDialectConfig);
|
|
7
|
+
init(): Promise<void>;
|
|
8
|
+
acquireConnection(): Promise<DatabaseConnection>;
|
|
9
|
+
beginTransaction(connection: DatabaseConnection): Promise<void>;
|
|
10
|
+
commitTransaction(connection: DatabaseConnection): Promise<void>;
|
|
11
|
+
rollbackTransaction(connection: DatabaseConnection): Promise<void>;
|
|
12
|
+
releaseConnection(): Promise<void>;
|
|
13
|
+
destroy(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { CompiledQuery } from '../../query-compiler/compiled-query.js';
|
|
2
|
+
import { importFunction } from '../../util/dynamic-import.js';
|
|
3
|
+
import { isBoolean, isFunction, isNumber } from '../../util/object-utils.js';
|
|
4
|
+
export class SqliteDriver {
|
|
5
|
+
#config;
|
|
6
|
+
#connectionMutex = new ConnectionMutex();
|
|
7
|
+
#db;
|
|
8
|
+
#connection;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.#config = config;
|
|
11
|
+
}
|
|
12
|
+
async init() {
|
|
13
|
+
// Import the `better-sqlite3` module here instead at the top of the file
|
|
14
|
+
// so that this file can be loaded by node without `better-sqlite3` driver
|
|
15
|
+
// installed. As you can see, there IS an import from `better-sqlite3` at
|
|
16
|
+
// the top level too, but that's only for types. It doesn't get compiled
|
|
17
|
+
// into javascript. You can check the built javascript code.
|
|
18
|
+
const DatabaseConstructor = await importBetterSqlite3Database();
|
|
19
|
+
const options = {};
|
|
20
|
+
if (isBoolean(this.#config.readonly)) {
|
|
21
|
+
options.readonly = this.#config.readonly;
|
|
22
|
+
}
|
|
23
|
+
if (isBoolean(this.#config.fileMustExist)) {
|
|
24
|
+
options.fileMustExist = this.#config.fileMustExist;
|
|
25
|
+
}
|
|
26
|
+
if (isNumber(this.#config.timeout)) {
|
|
27
|
+
options.timeout = this.#config.timeout;
|
|
28
|
+
}
|
|
29
|
+
if (isFunction(this.#config.verbose)) {
|
|
30
|
+
options.verbose = this.#config.verbose;
|
|
31
|
+
}
|
|
32
|
+
this.#db = new DatabaseConstructor(this.#config.databasePath, options);
|
|
33
|
+
this.#connection = new SqliteConnection(this.#db);
|
|
34
|
+
if (this.#config.onCreateConnection) {
|
|
35
|
+
await this.#config.onCreateConnection(this.#connection);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async acquireConnection() {
|
|
39
|
+
// SQLite only has one single connection. We use a mutex here to wait
|
|
40
|
+
// until the single connection has been released.
|
|
41
|
+
await this.#connectionMutex.lock();
|
|
42
|
+
return this.#connection;
|
|
43
|
+
}
|
|
44
|
+
async beginTransaction(connection) {
|
|
45
|
+
await connection.executeQuery(CompiledQuery.raw('begin'));
|
|
46
|
+
}
|
|
47
|
+
async commitTransaction(connection) {
|
|
48
|
+
await connection.executeQuery(CompiledQuery.raw('commit'));
|
|
49
|
+
}
|
|
50
|
+
async rollbackTransaction(connection) {
|
|
51
|
+
await connection.executeQuery(CompiledQuery.raw('rollback'));
|
|
52
|
+
}
|
|
53
|
+
async releaseConnection() {
|
|
54
|
+
this.#connectionMutex.unlock();
|
|
55
|
+
}
|
|
56
|
+
async destroy() {
|
|
57
|
+
this.#db?.close();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function importBetterSqlite3Database() {
|
|
61
|
+
try {
|
|
62
|
+
return await importFunction('better-sqlite3');
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
throw new Error('SQLite client not installed. Please run `npm install better-sqlite3`');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
class SqliteConnection {
|
|
69
|
+
#db;
|
|
70
|
+
constructor(db) {
|
|
71
|
+
this.#db = db;
|
|
72
|
+
}
|
|
73
|
+
executeQuery(compiledQuery) {
|
|
74
|
+
const { sql, parameters } = compiledQuery;
|
|
75
|
+
const stmt = this.#db.prepare(sql);
|
|
76
|
+
if (stmt.reader) {
|
|
77
|
+
return Promise.resolve({
|
|
78
|
+
rows: stmt.all(parameters),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const { changes, lastInsertRowid } = stmt.run(parameters);
|
|
83
|
+
return Promise.resolve({
|
|
84
|
+
numUpdatedOrDeletedRows: changes !== undefined && changes !== null
|
|
85
|
+
? BigInt(changes)
|
|
86
|
+
: undefined,
|
|
87
|
+
insertId: lastInsertRowid !== undefined && lastInsertRowid !== null
|
|
88
|
+
? BigInt(lastInsertRowid)
|
|
89
|
+
: undefined,
|
|
90
|
+
rows: [],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
class ConnectionMutex {
|
|
96
|
+
#promise;
|
|
97
|
+
#resolve;
|
|
98
|
+
async lock() {
|
|
99
|
+
while (this.#promise) {
|
|
100
|
+
await this.#promise;
|
|
101
|
+
}
|
|
102
|
+
this.#promise = new Promise((resolve) => {
|
|
103
|
+
this.#resolve = resolve;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
unlock() {
|
|
107
|
+
const resolve = this.#resolve;
|
|
108
|
+
this.#promise = undefined;
|
|
109
|
+
this.#resolve = undefined;
|
|
110
|
+
resolve?.();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DatabaseIntrospector, DatabaseMetadata, DatabaseMetadataOptions } from '../../introspection/database-introspector.js';
|
|
2
|
+
import { Kysely } from '../../kysely.js';
|
|
3
|
+
export declare class SqliteIntrospector implements DatabaseIntrospector {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(db: Kysely<any>);
|
|
6
|
+
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { MIGRATION_LOCK_TABLE, MIGRATION_TABLE, } from '../../migration/migration.js';
|
|
2
|
+
export class SqliteIntrospector {
|
|
3
|
+
#db;
|
|
4
|
+
constructor(db) {
|
|
5
|
+
this.#db = db;
|
|
6
|
+
}
|
|
7
|
+
async getMetadata(options = { withInternalKyselyTables: false }) {
|
|
8
|
+
let query = this.#db
|
|
9
|
+
.selectFrom('sqlite_schema')
|
|
10
|
+
.where('type', '=', 'table')
|
|
11
|
+
.where('name', 'not like', 'sqlite_%')
|
|
12
|
+
.select('name')
|
|
13
|
+
.castTo();
|
|
14
|
+
if (!options.withInternalKyselyTables) {
|
|
15
|
+
query = query
|
|
16
|
+
.where('name', '!=', MIGRATION_TABLE)
|
|
17
|
+
.where('name', '!=', MIGRATION_LOCK_TABLE);
|
|
18
|
+
}
|
|
19
|
+
const tables = await query.execute();
|
|
20
|
+
return {
|
|
21
|
+
tables: await Promise.all(tables.map(({ name }) => this.#getTableMetadata(name))),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async #getTableMetadata(table) {
|
|
25
|
+
const db = this.#db;
|
|
26
|
+
const columns = await db
|
|
27
|
+
.selectFrom(db.raw(`PRAGMA_TABLE_INFO(?)`, [table]).as('table_info'))
|
|
28
|
+
.select(['name', 'type', 'notnull'])
|
|
29
|
+
.castTo()
|
|
30
|
+
.execute();
|
|
31
|
+
return {
|
|
32
|
+
name: table,
|
|
33
|
+
columns: columns.map((col) => ({
|
|
34
|
+
name: col.name,
|
|
35
|
+
dataType: col.type,
|
|
36
|
+
isNullable: !col.notnull,
|
|
37
|
+
})),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';
|
|
2
|
+
export declare class SqliteQueryCompiler extends DefaultQueryCompiler {
|
|
3
|
+
protected getCurrentParameterPlaceholder(): string;
|
|
4
|
+
protected getLeftIdentifierWrapper(): string;
|
|
5
|
+
protected getRightIdentifierWrapper(): string;
|
|
6
|
+
protected getAutoIncrement(): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';
|
|
2
|
+
export class SqliteQueryCompiler extends DefaultQueryCompiler {
|
|
3
|
+
getCurrentParameterPlaceholder() {
|
|
4
|
+
return '?';
|
|
5
|
+
}
|
|
6
|
+
getLeftIdentifierWrapper() {
|
|
7
|
+
return '"';
|
|
8
|
+
}
|
|
9
|
+
getRightIdentifierWrapper() {
|
|
10
|
+
return '"';
|
|
11
|
+
}
|
|
12
|
+
getAutoIncrement() {
|
|
13
|
+
return 'autoincrement';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -12,12 +12,12 @@ export interface QueryResult<O> {
|
|
|
12
12
|
* This is defined for update and delete queries and contains
|
|
13
13
|
* the number of rows the query updated/deleted.
|
|
14
14
|
*/
|
|
15
|
-
readonly numUpdatedOrDeletedRows?:
|
|
15
|
+
readonly numUpdatedOrDeletedRows?: bigint;
|
|
16
16
|
/**
|
|
17
17
|
* This is defined for insert queries on dialects that return
|
|
18
18
|
* the auto incrementing primary key from an insert.
|
|
19
19
|
*/
|
|
20
|
-
readonly
|
|
20
|
+
readonly insertId?: bigint;
|
|
21
21
|
/**
|
|
22
22
|
* The rows returned by the query. This is always defined and is
|
|
23
23
|
* empty if the query returned no rows.
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export * from './query-creator.js';
|
|
|
3
3
|
export * from './query-builder/query-builder.js';
|
|
4
4
|
export * from './query-builder/join-builder.js';
|
|
5
5
|
export * from './query-builder/expression-builder.js';
|
|
6
|
+
export * from './query-builder/insert-result.js';
|
|
7
|
+
export * from './query-builder/delete-result.js';
|
|
8
|
+
export * from './query-builder/update-result.js';
|
|
6
9
|
export * from './raw-builder/raw-builder.js';
|
|
7
10
|
export * from './query-executor/query-executor.js';
|
|
8
11
|
export * from './query-executor/default-query-executor.js';
|
|
@@ -37,41 +40,19 @@ export * from './dialect/mysql/mysql-query-compiler.js';
|
|
|
37
40
|
export * from './dialect/mysql/mysql-driver.js';
|
|
38
41
|
export * from './dialect/mysql/mysql-introspector.js';
|
|
39
42
|
export * from './dialect/mysql/mysql-adapter.js';
|
|
43
|
+
export * from './dialect/sqlite/sqlite-dialect.js';
|
|
44
|
+
export * from './dialect/sqlite/sqlite-query-compiler.js';
|
|
45
|
+
export * from './dialect/sqlite/sqlite-driver.js';
|
|
46
|
+
export * from './dialect/sqlite/sqlite-introspector.js';
|
|
47
|
+
export * from './dialect/sqlite/sqlite-adapter.js';
|
|
40
48
|
export * from './query-compiler/default-query-compiler.js';
|
|
41
49
|
export * from './query-compiler/query-compiler.js';
|
|
42
50
|
export * from './migration/migration.js';
|
|
43
51
|
export * from './dialect/dialect.js';
|
|
44
52
|
export * from './dialect/dialect-adapter.js';
|
|
45
53
|
export * from './dialect/dialect-adapter-base.js';
|
|
46
|
-
export * from './operation-node/operation-node-transformer.js';
|
|
47
|
-
export * from './operation-node/operation-node-visitor.js';
|
|
48
54
|
export * from './plugin/kysely-plugin.js';
|
|
49
55
|
export * from './plugin/camel-case/camel-case-plugin.js';
|
|
50
|
-
export * from './operation-node/operation-node-transformer.js';
|
|
51
|
-
export * from './operation-node/operation-node-visitor.js';
|
|
52
|
-
export * from './operation-node/operator-node.js';
|
|
53
|
-
export * from './operation-node/or-node.js';
|
|
54
|
-
export * from './operation-node/order-by-item-node.js';
|
|
55
|
-
export * from './operation-node/order-by-node.js';
|
|
56
|
-
export * from './operation-node/parens-node.js';
|
|
57
|
-
export * from './operation-node/primary-constraint-node.js';
|
|
58
|
-
export * from './operation-node/primitive-value-list-node.js';
|
|
59
|
-
export * from './operation-node/query-node.js';
|
|
60
|
-
export * from './operation-node/raw-node.js';
|
|
61
|
-
export * from './operation-node/reference-node.js';
|
|
62
|
-
export * from './operation-node/references-node.js';
|
|
63
|
-
export * from './operation-node/rename-column-node.js';
|
|
64
|
-
export * from './operation-node/returning-node.js';
|
|
65
|
-
export * from './operation-node/select-all-node.js';
|
|
66
|
-
export * from './operation-node/select-query-node.js';
|
|
67
|
-
export * from './operation-node/selection-node.js';
|
|
68
|
-
export * from './operation-node/table-node.js';
|
|
69
|
-
export * from './operation-node/unique-constraint-node.js';
|
|
70
|
-
export * from './operation-node/update-query-node.js';
|
|
71
|
-
export * from './operation-node/value-list-node.js';
|
|
72
|
-
export * from './operation-node/value-node.js';
|
|
73
|
-
export * from './operation-node/where-node.js';
|
|
74
|
-
export * from './operation-node/with-node.js';
|
|
75
56
|
export * from './operation-node/add-column-node.js';
|
|
76
57
|
export * from './operation-node/add-constraint-node.js';
|
|
77
58
|
export * from './operation-node/alias-node.js';
|
|
@@ -87,16 +68,20 @@ export * from './operation-node/constraint-node.js';
|
|
|
87
68
|
export * from './operation-node/create-index-node.js';
|
|
88
69
|
export * from './operation-node/create-schema-node.js';
|
|
89
70
|
export * from './operation-node/create-table-node.js';
|
|
71
|
+
export * from './operation-node/create-view-node.js';
|
|
90
72
|
export * from './operation-node/data-type-node.js';
|
|
73
|
+
export * from './operation-node/default-value-node.js';
|
|
91
74
|
export * from './operation-node/delete-query-node.js';
|
|
92
75
|
export * from './operation-node/drop-column-node.js';
|
|
93
76
|
export * from './operation-node/drop-constraint-node.js';
|
|
94
77
|
export * from './operation-node/drop-index-node.js';
|
|
95
78
|
export * from './operation-node/drop-schema-node.js';
|
|
96
79
|
export * from './operation-node/drop-table-node.js';
|
|
80
|
+
export * from './operation-node/drop-view-node.js';
|
|
97
81
|
export * from './operation-node/filter-node.js';
|
|
98
82
|
export * from './operation-node/foreign-key-constraint-node.js';
|
|
99
83
|
export * from './operation-node/from-node.js';
|
|
84
|
+
export * from './operation-node/generated-always-as-node.js';
|
|
100
85
|
export * from './operation-node/group-by-item-node.js';
|
|
101
86
|
export * from './operation-node/group-by-node.js';
|
|
102
87
|
export * from './operation-node/having-node.js';
|
|
@@ -105,19 +90,50 @@ export * from './operation-node/insert-query-node.js';
|
|
|
105
90
|
export * from './operation-node/join-node.js';
|
|
106
91
|
export * from './operation-node/limit-node.js';
|
|
107
92
|
export * from './operation-node/list-node.js';
|
|
93
|
+
export * from './operation-node/modify-column-node.js';
|
|
108
94
|
export * from './operation-node/offset-node.js';
|
|
109
|
-
export * from './operation-node
|
|
110
|
-
export * from './operation-node/
|
|
95
|
+
export * from './operation-node/on-conflict-node.js';
|
|
96
|
+
export * from './operation-node/on-duplicate-key-node.js';
|
|
97
|
+
export * from './operation-node/on-node.js';
|
|
111
98
|
export * from './operation-node/operation-node-source.js';
|
|
99
|
+
export * from './operation-node/operation-node-transformer.js';
|
|
100
|
+
export * from './operation-node/operation-node-utils.js';
|
|
101
|
+
export * from './operation-node/operation-node-visitor.js';
|
|
102
|
+
export * from './operation-node/operation-node.js';
|
|
103
|
+
export * from './operation-node/operator-node.js';
|
|
104
|
+
export * from './operation-node/or-node.js';
|
|
105
|
+
export * from './operation-node/order-by-item-node.js';
|
|
112
106
|
export * from './operation-node/order-by-node.js';
|
|
107
|
+
export * from './operation-node/parens-node.js';
|
|
108
|
+
export * from './operation-node/primary-constraint-node.js';
|
|
109
|
+
export * from './operation-node/primitive-value-list-node.js';
|
|
110
|
+
export * from './operation-node/query-node.js';
|
|
111
|
+
export * from './operation-node/raw-node.js';
|
|
112
|
+
export * from './operation-node/reference-node.js';
|
|
113
|
+
export * from './operation-node/references-node.js';
|
|
114
|
+
export * from './operation-node/rename-column-node.js';
|
|
115
|
+
export * from './operation-node/returning-node.js';
|
|
116
|
+
export * from './operation-node/select-all-node.js';
|
|
117
|
+
export * from './operation-node/select-query-node.js';
|
|
118
|
+
export * from './operation-node/select-query-node.js';
|
|
119
|
+
export * from './operation-node/selection-node.js';
|
|
120
|
+
export * from './operation-node/table-node.js';
|
|
121
|
+
export * from './operation-node/union-node.js';
|
|
122
|
+
export * from './operation-node/unique-constraint-node.js';
|
|
123
|
+
export * from './operation-node/update-query-node.js';
|
|
124
|
+
export * from './operation-node/value-list-node.js';
|
|
125
|
+
export * from './operation-node/value-node.js';
|
|
126
|
+
export * from './operation-node/where-node.js';
|
|
127
|
+
export * from './operation-node/with-node.js';
|
|
113
128
|
export * from './introspection/database-introspector.js';
|
|
114
129
|
export * from './util/compilable.js';
|
|
130
|
+
export * from './util/log.js';
|
|
115
131
|
export { AnyColumn, UnknownRow, AnyQueryBuilder } from './util/type-utils.js';
|
|
116
132
|
export { SelectExpression, SelectExpressionOrList, } from './parser/select-parser.js';
|
|
117
133
|
export { ReferenceExpression, ReferenceExpressionOrList, } from './parser/reference-parser.js';
|
|
118
134
|
export { ValueExpression, ValueExpressionOrList, } from './parser/value-parser.js';
|
|
119
135
|
export { ExistsExpression, FilterOperator } from './parser/filter-parser.js';
|
|
120
|
-
export { TableExpression } from './parser/table-parser.js';
|
|
136
|
+
export { TableExpression, TableExpressionOrList, } from './parser/table-parser.js';
|
|
121
137
|
export { JoinReferenceExpression, JoinCallbackExpression, } from './parser/join-parser.js';
|
|
122
138
|
export { InsertObject } from './parser/insert-values-parser.js';
|
|
123
139
|
export { MutationObject } from './parser/update-set-parser.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -3,6 +3,9 @@ export * from './query-creator.js';
|
|
|
3
3
|
export * from './query-builder/query-builder.js';
|
|
4
4
|
export * from './query-builder/join-builder.js';
|
|
5
5
|
export * from './query-builder/expression-builder.js';
|
|
6
|
+
export * from './query-builder/insert-result.js';
|
|
7
|
+
export * from './query-builder/delete-result.js';
|
|
8
|
+
export * from './query-builder/update-result.js';
|
|
6
9
|
export * from './raw-builder/raw-builder.js';
|
|
7
10
|
export * from './query-executor/query-executor.js';
|
|
8
11
|
export * from './query-executor/default-query-executor.js';
|
|
@@ -37,41 +40,19 @@ export * from './dialect/mysql/mysql-query-compiler.js';
|
|
|
37
40
|
export * from './dialect/mysql/mysql-driver.js';
|
|
38
41
|
export * from './dialect/mysql/mysql-introspector.js';
|
|
39
42
|
export * from './dialect/mysql/mysql-adapter.js';
|
|
43
|
+
export * from './dialect/sqlite/sqlite-dialect.js';
|
|
44
|
+
export * from './dialect/sqlite/sqlite-query-compiler.js';
|
|
45
|
+
export * from './dialect/sqlite/sqlite-driver.js';
|
|
46
|
+
export * from './dialect/sqlite/sqlite-introspector.js';
|
|
47
|
+
export * from './dialect/sqlite/sqlite-adapter.js';
|
|
40
48
|
export * from './query-compiler/default-query-compiler.js';
|
|
41
49
|
export * from './query-compiler/query-compiler.js';
|
|
42
50
|
export * from './migration/migration.js';
|
|
43
51
|
export * from './dialect/dialect.js';
|
|
44
52
|
export * from './dialect/dialect-adapter.js';
|
|
45
53
|
export * from './dialect/dialect-adapter-base.js';
|
|
46
|
-
export * from './operation-node/operation-node-transformer.js';
|
|
47
|
-
export * from './operation-node/operation-node-visitor.js';
|
|
48
54
|
export * from './plugin/kysely-plugin.js';
|
|
49
55
|
export * from './plugin/camel-case/camel-case-plugin.js';
|
|
50
|
-
export * from './operation-node/operation-node-transformer.js';
|
|
51
|
-
export * from './operation-node/operation-node-visitor.js';
|
|
52
|
-
export * from './operation-node/operator-node.js';
|
|
53
|
-
export * from './operation-node/or-node.js';
|
|
54
|
-
export * from './operation-node/order-by-item-node.js';
|
|
55
|
-
export * from './operation-node/order-by-node.js';
|
|
56
|
-
export * from './operation-node/parens-node.js';
|
|
57
|
-
export * from './operation-node/primary-constraint-node.js';
|
|
58
|
-
export * from './operation-node/primitive-value-list-node.js';
|
|
59
|
-
export * from './operation-node/query-node.js';
|
|
60
|
-
export * from './operation-node/raw-node.js';
|
|
61
|
-
export * from './operation-node/reference-node.js';
|
|
62
|
-
export * from './operation-node/references-node.js';
|
|
63
|
-
export * from './operation-node/rename-column-node.js';
|
|
64
|
-
export * from './operation-node/returning-node.js';
|
|
65
|
-
export * from './operation-node/select-all-node.js';
|
|
66
|
-
export * from './operation-node/select-query-node.js';
|
|
67
|
-
export * from './operation-node/selection-node.js';
|
|
68
|
-
export * from './operation-node/table-node.js';
|
|
69
|
-
export * from './operation-node/unique-constraint-node.js';
|
|
70
|
-
export * from './operation-node/update-query-node.js';
|
|
71
|
-
export * from './operation-node/value-list-node.js';
|
|
72
|
-
export * from './operation-node/value-node.js';
|
|
73
|
-
export * from './operation-node/where-node.js';
|
|
74
|
-
export * from './operation-node/with-node.js';
|
|
75
56
|
export * from './operation-node/add-column-node.js';
|
|
76
57
|
export * from './operation-node/add-constraint-node.js';
|
|
77
58
|
export * from './operation-node/alias-node.js';
|
|
@@ -87,16 +68,20 @@ export * from './operation-node/constraint-node.js';
|
|
|
87
68
|
export * from './operation-node/create-index-node.js';
|
|
88
69
|
export * from './operation-node/create-schema-node.js';
|
|
89
70
|
export * from './operation-node/create-table-node.js';
|
|
71
|
+
export * from './operation-node/create-view-node.js';
|
|
90
72
|
export * from './operation-node/data-type-node.js';
|
|
73
|
+
export * from './operation-node/default-value-node.js';
|
|
91
74
|
export * from './operation-node/delete-query-node.js';
|
|
92
75
|
export * from './operation-node/drop-column-node.js';
|
|
93
76
|
export * from './operation-node/drop-constraint-node.js';
|
|
94
77
|
export * from './operation-node/drop-index-node.js';
|
|
95
78
|
export * from './operation-node/drop-schema-node.js';
|
|
96
79
|
export * from './operation-node/drop-table-node.js';
|
|
80
|
+
export * from './operation-node/drop-view-node.js';
|
|
97
81
|
export * from './operation-node/filter-node.js';
|
|
98
82
|
export * from './operation-node/foreign-key-constraint-node.js';
|
|
99
83
|
export * from './operation-node/from-node.js';
|
|
84
|
+
export * from './operation-node/generated-always-as-node.js';
|
|
100
85
|
export * from './operation-node/group-by-item-node.js';
|
|
101
86
|
export * from './operation-node/group-by-node.js';
|
|
102
87
|
export * from './operation-node/having-node.js';
|
|
@@ -105,10 +90,41 @@ export * from './operation-node/insert-query-node.js';
|
|
|
105
90
|
export * from './operation-node/join-node.js';
|
|
106
91
|
export * from './operation-node/limit-node.js';
|
|
107
92
|
export * from './operation-node/list-node.js';
|
|
93
|
+
export * from './operation-node/modify-column-node.js';
|
|
108
94
|
export * from './operation-node/offset-node.js';
|
|
109
|
-
export * from './operation-node
|
|
110
|
-
export * from './operation-node/
|
|
95
|
+
export * from './operation-node/on-conflict-node.js';
|
|
96
|
+
export * from './operation-node/on-duplicate-key-node.js';
|
|
97
|
+
export * from './operation-node/on-node.js';
|
|
111
98
|
export * from './operation-node/operation-node-source.js';
|
|
99
|
+
export * from './operation-node/operation-node-transformer.js';
|
|
100
|
+
export * from './operation-node/operation-node-utils.js';
|
|
101
|
+
export * from './operation-node/operation-node-visitor.js';
|
|
102
|
+
export * from './operation-node/operation-node.js';
|
|
103
|
+
export * from './operation-node/operator-node.js';
|
|
104
|
+
export * from './operation-node/or-node.js';
|
|
105
|
+
export * from './operation-node/order-by-item-node.js';
|
|
112
106
|
export * from './operation-node/order-by-node.js';
|
|
107
|
+
export * from './operation-node/parens-node.js';
|
|
108
|
+
export * from './operation-node/primary-constraint-node.js';
|
|
109
|
+
export * from './operation-node/primitive-value-list-node.js';
|
|
110
|
+
export * from './operation-node/query-node.js';
|
|
111
|
+
export * from './operation-node/raw-node.js';
|
|
112
|
+
export * from './operation-node/reference-node.js';
|
|
113
|
+
export * from './operation-node/references-node.js';
|
|
114
|
+
export * from './operation-node/rename-column-node.js';
|
|
115
|
+
export * from './operation-node/returning-node.js';
|
|
116
|
+
export * from './operation-node/select-all-node.js';
|
|
117
|
+
export * from './operation-node/select-query-node.js';
|
|
118
|
+
export * from './operation-node/select-query-node.js';
|
|
119
|
+
export * from './operation-node/selection-node.js';
|
|
120
|
+
export * from './operation-node/table-node.js';
|
|
121
|
+
export * from './operation-node/union-node.js';
|
|
122
|
+
export * from './operation-node/unique-constraint-node.js';
|
|
123
|
+
export * from './operation-node/update-query-node.js';
|
|
124
|
+
export * from './operation-node/value-list-node.js';
|
|
125
|
+
export * from './operation-node/value-node.js';
|
|
126
|
+
export * from './operation-node/where-node.js';
|
|
127
|
+
export * from './operation-node/with-node.js';
|
|
113
128
|
export * from './introspection/database-introspector.js';
|
|
114
129
|
export * from './util/compilable.js';
|
|
130
|
+
export * from './util/log.js';
|
package/dist/esm/kysely.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ 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
|
*
|
|
@@ -116,7 +116,7 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
116
116
|
* .execute()
|
|
117
117
|
* ```
|
|
118
118
|
*
|
|
119
|
-
* The generated SQL (
|
|
119
|
+
* The generated SQL (PostgreSQL):
|
|
120
120
|
*
|
|
121
121
|
* ```sql
|
|
122
122
|
* select "person"."id", count("pet"."id") as "pet_count"
|
|
@@ -146,17 +146,19 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
146
146
|
* const catto = await db.transaction().execute(async (trx) => {
|
|
147
147
|
* const jennifer = await trx.insertInto('person')
|
|
148
148
|
* .values({
|
|
149
|
+
* id: db.generated,
|
|
149
150
|
* first_name: 'Jennifer',
|
|
150
|
-
*
|
|
151
|
+
* last_name: 'Aniston',
|
|
151
152
|
* })
|
|
152
153
|
* .returning('id')
|
|
153
|
-
* .
|
|
154
|
+
* .executeTakeFirstOrThrow()
|
|
154
155
|
*
|
|
155
156
|
* await someFunction(trx, jennifer)
|
|
156
157
|
*
|
|
157
158
|
* return await trx.insertInto('pet')
|
|
158
159
|
* .values({
|
|
159
|
-
*
|
|
160
|
+
* id: db.generated,
|
|
161
|
+
* user_id: jennifer.id,
|
|
160
162
|
* name: 'Catto',
|
|
161
163
|
* species: 'cat'
|
|
162
164
|
* })
|
|
@@ -233,17 +235,33 @@ export interface KyselyConfig {
|
|
|
233
235
|
readonly dialect: Dialect;
|
|
234
236
|
readonly plugins?: KyselyPlugin[];
|
|
235
237
|
/**
|
|
236
|
-
* A list of log levels to log.
|
|
238
|
+
* A list of log levels to log or a custom logger function.
|
|
237
239
|
*
|
|
238
240
|
* Currently there's only two levels: `query` and `error`.
|
|
239
241
|
* This will be expanded based on user feedback later.
|
|
240
242
|
*
|
|
241
|
-
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* const db = new Kysely<Database>({
|
|
246
|
+
* dialect: new PostgresDialect(postgresConfig),
|
|
247
|
+
* log: ['query', 'error']
|
|
248
|
+
* })
|
|
249
|
+
* ```
|
|
242
250
|
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* const db = new Kysely<Database>({
|
|
254
|
+
* dialect: new PostgresDialect(postgresConfig),
|
|
255
|
+
* log(event): void {
|
|
256
|
+
* if (event.level === 'query') {
|
|
257
|
+
* console.log(event.query.sql)
|
|
258
|
+
* console.log(event.query.parameters)
|
|
259
|
+
* }
|
|
260
|
+
* }
|
|
261
|
+
* })
|
|
262
|
+
* ```
|
|
245
263
|
*/
|
|
246
|
-
readonly log?:
|
|
264
|
+
readonly log?: LogConfig;
|
|
247
265
|
}
|
|
248
266
|
export declare class ConnectionBuilder<DB> {
|
|
249
267
|
#private;
|