kysely 0.15.2 → 0.16.2
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 -9
- package/dist/cjs/dialect/database-introspector.d.ts +1 -1
- package/dist/cjs/dialect/dialect-adapter-base.d.ts +1 -1
- package/dist/cjs/dialect/dialect-adapter.d.ts +1 -1
- package/dist/cjs/dialect/dialect.d.ts +2 -2
- package/dist/cjs/dialect/mysql/mysql-adapter.d.ts +1 -1
- package/dist/cjs/dialect/mysql/mysql-dialect.d.ts +2 -2
- package/dist/cjs/dialect/mysql/mysql-introspector.d.ts +1 -1
- package/dist/cjs/dialect/postgres/postgres-adapter.d.ts +1 -1
- package/dist/cjs/dialect/postgres/postgres-dialect.d.ts +2 -2
- package/dist/cjs/dialect/postgres/postgres-introspector.d.ts +1 -1
- package/dist/cjs/dialect/sqlite/sqlite-adapter.d.ts +1 -1
- package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +2 -2
- package/dist/cjs/dialect/sqlite/sqlite-introspector.d.ts +1 -1
- package/dist/cjs/kysely.js +9 -5
- package/dist/cjs/migration/file-migration-provider.d.ts +2 -25
- package/dist/cjs/migration/file-migration-provider.js +8 -17
- package/dist/cjs/migration/migrator.d.ts +2 -15
- package/dist/cjs/migration/migrator.js +2 -15
- package/dist/cjs/operation-node/constraint-node.d.ts +4 -4
- package/dist/cjs/parser/join-parser.d.ts +4 -4
- package/dist/cjs/plugin/camel-case/camel-case-plugin.js +1 -1
- package/dist/cjs/query-builder/delete-query-builder.d.ts +3 -3
- package/dist/cjs/query-builder/join-interface.d.ts +3 -3
- package/dist/cjs/query-builder/select-query-builder.d.ts +3 -3
- package/dist/cjs/query-builder/update-query-builder.d.ts +3 -3
- package/dist/cjs/util/object-utils.d.ts +1 -1
- package/dist/cjs/util/object-utils.js +8 -8
- package/dist/esm/dialect/database-introspector.d.ts +1 -1
- package/dist/esm/dialect/dialect-adapter-base.d.ts +1 -1
- package/dist/esm/dialect/dialect-adapter.d.ts +1 -1
- package/dist/esm/dialect/dialect.d.ts +2 -2
- package/dist/esm/dialect/mysql/mysql-adapter.d.ts +1 -1
- package/dist/esm/dialect/mysql/mysql-dialect.d.ts +2 -2
- package/dist/esm/dialect/mysql/mysql-introspector.d.ts +1 -1
- package/dist/esm/dialect/postgres/postgres-adapter.d.ts +1 -1
- package/dist/esm/dialect/postgres/postgres-dialect.d.ts +2 -2
- package/dist/esm/dialect/postgres/postgres-introspector.d.ts +1 -1
- package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +1 -1
- package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +2 -2
- package/dist/esm/dialect/sqlite/sqlite-introspector.d.ts +1 -1
- package/dist/esm/kysely.js +9 -5
- package/dist/esm/migration/file-migration-provider.d.ts +2 -25
- package/dist/esm/migration/file-migration-provider.js +8 -17
- package/dist/esm/migration/migrator.d.ts +2 -15
- package/dist/esm/migration/migrator.js +2 -15
- package/dist/esm/operation-node/constraint-node.d.ts +4 -4
- package/dist/esm/parser/join-parser.d.ts +4 -4
- package/dist/esm/plugin/camel-case/camel-case-plugin.js +2 -2
- package/dist/esm/query-builder/delete-query-builder.d.ts +3 -3
- package/dist/esm/query-builder/join-interface.d.ts +3 -3
- package/dist/esm/query-builder/select-query-builder.d.ts +3 -3
- package/dist/esm/query-builder/update-query-builder.d.ts +3 -3
- package/dist/esm/util/object-utils.d.ts +1 -1
- package/dist/esm/util/object-utils.js +6 -6
- package/package.json +4 -2
- package/test.js +0 -3
package/README.md
CHANGED
|
@@ -303,9 +303,6 @@ need to depend on a typescript compiler, which most production environments don'
|
|
|
303
303
|
have. You will probably want to add a simple migration script to your projects like this:
|
|
304
304
|
|
|
305
305
|
```ts
|
|
306
|
-
import * as path from 'path'
|
|
307
|
-
import * as fs from 'fs/promises'
|
|
308
|
-
|
|
309
306
|
import {
|
|
310
307
|
Kysely,
|
|
311
308
|
Migrator,
|
|
@@ -323,14 +320,9 @@ async function migrateToLatest() {
|
|
|
323
320
|
|
|
324
321
|
const migrator = new Migrator({
|
|
325
322
|
db,
|
|
326
|
-
// The constructor signature of FileMigrationProvider is a
|
|
327
|
-
// bit weird to keep Kysely independent of node.js or any
|
|
328
|
-
// other environment.
|
|
329
323
|
provider: new FileMigrationProvider(
|
|
330
|
-
fs.readdir,
|
|
331
|
-
path.join,
|
|
332
324
|
// Path to the folder that contains all your migrations.
|
|
333
|
-
'migrations'
|
|
325
|
+
'some/path/to/migrations'
|
|
334
326
|
)
|
|
335
327
|
})
|
|
336
328
|
|
|
@@ -4,7 +4,7 @@ import { ColumnDataType } from '../operation-node/data-type-node.js';
|
|
|
4
4
|
*/
|
|
5
5
|
export interface DatabaseIntrospector {
|
|
6
6
|
/**
|
|
7
|
-
* Get the database metadata such as
|
|
7
|
+
* Get the database metadata such as table and column names.
|
|
8
8
|
*/
|
|
9
9
|
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
10
10
|
}
|
|
@@ -20,7 +20,7 @@ export declare abstract class DialectAdapterBase implements DialectAdapter {
|
|
|
20
20
|
get supportsReturning(): boolean;
|
|
21
21
|
/**
|
|
22
22
|
* This method is used to acquire a lock for the migrations so that
|
|
23
|
-
* it's not possible for two migration
|
|
23
|
+
* it's not possible for two migration operations to run in parallel.
|
|
24
24
|
*
|
|
25
25
|
* Most dialects have explicit locks that can be used, like advisory locks
|
|
26
26
|
* in PostgreSQL and the get_lock function in MySQL.
|
|
@@ -21,7 +21,7 @@ export interface DialectAdapter {
|
|
|
21
21
|
readonly supportsReturning: boolean;
|
|
22
22
|
/**
|
|
23
23
|
* This method is used to acquire a lock for the migrations so that
|
|
24
|
-
* it's not possible for two migration
|
|
24
|
+
* it's not possible for two migration operations to run in parallel.
|
|
25
25
|
*
|
|
26
26
|
* Most dialects have explicit locks that can be used, like advisory locks
|
|
27
27
|
* in PostgreSQL and the get_lock function in MySQL.
|
|
@@ -24,8 +24,8 @@ export interface Dialect {
|
|
|
24
24
|
*/
|
|
25
25
|
createAdapter(): DialectAdapter;
|
|
26
26
|
/**
|
|
27
|
-
* Creates a database introspector that can be used to get
|
|
28
|
-
* such as the
|
|
27
|
+
* Creates a database introspector that can be used to get database metadata
|
|
28
|
+
* such as the table names and column names of those tables.
|
|
29
29
|
*
|
|
30
30
|
* `db` never has any plugins installed. It's created using
|
|
31
31
|
* {@link Kysely.withoutPlugins}.
|
|
@@ -14,7 +14,7 @@ export declare class MysqlAdapter extends DialectAdapterBase {
|
|
|
14
14
|
get supportsReturning(): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* This method is used to acquire a lock for the migrations so that
|
|
17
|
-
* it's not possible for two migration
|
|
17
|
+
* it's not possible for two migration operations to run in parallel.
|
|
18
18
|
*
|
|
19
19
|
* Most dialects have explicit locks that can be used, like advisory locks
|
|
20
20
|
* in PostgreSQL and the get_lock function in MySQL.
|
|
@@ -28,8 +28,8 @@ export declare class MysqlDialect implements Dialect {
|
|
|
28
28
|
*/
|
|
29
29
|
createAdapter(): DialectAdapter;
|
|
30
30
|
/**
|
|
31
|
-
* Creates a database introspector that can be used to get
|
|
32
|
-
* such as the
|
|
31
|
+
* Creates a database introspector that can be used to get database metadata
|
|
32
|
+
* such as the table names and column names of those tables.
|
|
33
33
|
*
|
|
34
34
|
* `db` never has any plugins installed. It's created using
|
|
35
35
|
* {@link Kysely.withoutPlugins}.
|
|
@@ -4,7 +4,7 @@ export declare class MysqlIntrospector implements DatabaseIntrospector {
|
|
|
4
4
|
#private;
|
|
5
5
|
constructor(db: Kysely<any>);
|
|
6
6
|
/**
|
|
7
|
-
* Get the database metadata such as
|
|
7
|
+
* Get the database metadata such as table and column names.
|
|
8
8
|
*/
|
|
9
9
|
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
10
10
|
}
|
|
@@ -14,7 +14,7 @@ export declare class PostgresAdapter extends DialectAdapterBase {
|
|
|
14
14
|
get supportsReturning(): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* This method is used to acquire a lock for the migrations so that
|
|
17
|
-
* it's not possible for two migration
|
|
17
|
+
* it's not possible for two migration operations to run in parallel.
|
|
18
18
|
*
|
|
19
19
|
* Most dialects have explicit locks that can be used, like advisory locks
|
|
20
20
|
* in PostgreSQL and the get_lock function in MySQL.
|
|
@@ -34,8 +34,8 @@ export declare class PostgresDialect implements Dialect {
|
|
|
34
34
|
*/
|
|
35
35
|
createAdapter(): DialectAdapter;
|
|
36
36
|
/**
|
|
37
|
-
* Creates a database introspector that can be used to get
|
|
38
|
-
* such as the
|
|
37
|
+
* Creates a database introspector that can be used to get database metadata
|
|
38
|
+
* such as the table names and column names of those tables.
|
|
39
39
|
*
|
|
40
40
|
* `db` never has any plugins installed. It's created using
|
|
41
41
|
* {@link Kysely.withoutPlugins}.
|
|
@@ -4,7 +4,7 @@ export declare class PostgresIntrospector implements DatabaseIntrospector {
|
|
|
4
4
|
#private;
|
|
5
5
|
constructor(db: Kysely<any>);
|
|
6
6
|
/**
|
|
7
|
-
* Get the database metadata such as
|
|
7
|
+
* Get the database metadata such as table and column names.
|
|
8
8
|
*/
|
|
9
9
|
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
10
10
|
}
|
|
@@ -13,7 +13,7 @@ export declare class SqliteAdapter implements DialectAdapterBase {
|
|
|
13
13
|
get supportsReturning(): boolean;
|
|
14
14
|
/**
|
|
15
15
|
* This method is used to acquire a lock for the migrations so that
|
|
16
|
-
* it's not possible for two migration
|
|
16
|
+
* it's not possible for two migration operations to run in parallel.
|
|
17
17
|
*
|
|
18
18
|
* Most dialects have explicit locks that can be used, like advisory locks
|
|
19
19
|
* in PostgreSQL and the get_lock function in MySQL.
|
|
@@ -28,8 +28,8 @@ export declare class SqliteDialect implements Dialect {
|
|
|
28
28
|
*/
|
|
29
29
|
createAdapter(): DialectAdapter;
|
|
30
30
|
/**
|
|
31
|
-
* Creates a database introspector that can be used to get
|
|
32
|
-
* such as the
|
|
31
|
+
* Creates a database introspector that can be used to get database metadata
|
|
32
|
+
* such as the table names and column names of those tables.
|
|
33
33
|
*
|
|
34
34
|
* `db` never has any plugins installed. It's created using
|
|
35
35
|
* {@link Kysely.withoutPlugins}.
|
|
@@ -4,7 +4,7 @@ export declare class SqliteIntrospector implements DatabaseIntrospector {
|
|
|
4
4
|
#private;
|
|
5
5
|
constructor(db: Kysely<any>);
|
|
6
6
|
/**
|
|
7
|
-
* Get the database metadata such as
|
|
7
|
+
* Get the database metadata such as table and column names.
|
|
8
8
|
*/
|
|
9
9
|
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
10
10
|
}
|
package/dist/cjs/kysely.js
CHANGED
|
@@ -59,9 +59,11 @@ const private_symbols_js_1 = require("./util/private-symbols.js");
|
|
|
59
59
|
class Kysely extends query_creator_js_1.QueryCreator {
|
|
60
60
|
#props;
|
|
61
61
|
constructor(args) {
|
|
62
|
+
let superProps;
|
|
63
|
+
let props;
|
|
62
64
|
if (isKyselyProps(args)) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
superProps = { executor: args.executor, parseContext: args.parseContext };
|
|
66
|
+
props = { ...args };
|
|
65
67
|
}
|
|
66
68
|
else {
|
|
67
69
|
const dialect = args.dialect;
|
|
@@ -73,15 +75,17 @@ class Kysely extends query_creator_js_1.QueryCreator {
|
|
|
73
75
|
const runtimeDriver = new runtime_driver_js_1.RuntimeDriver(driver, log);
|
|
74
76
|
const connectionProvider = new default_connection_provider_js_1.DefaultConnectionProvider(runtimeDriver);
|
|
75
77
|
const executor = new default_query_executor_js_1.DefaultQueryExecutor(compiler, connectionProvider, args.plugins ?? []);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
superProps = { executor, parseContext };
|
|
79
|
+
props = {
|
|
78
80
|
config: args,
|
|
79
81
|
executor,
|
|
80
82
|
dialect,
|
|
81
83
|
driver: runtimeDriver,
|
|
82
84
|
parseContext,
|
|
83
|
-
}
|
|
85
|
+
};
|
|
84
86
|
}
|
|
87
|
+
super(superProps);
|
|
88
|
+
this.#props = (0, object_utils_js_1.freeze)(props);
|
|
85
89
|
}
|
|
86
90
|
/**
|
|
87
91
|
* Returns the {@link SchemaModule} module for building database schema.
|
|
@@ -1,41 +1,18 @@
|
|
|
1
1
|
import { Migration, MigrationProvider } from './migrator.js';
|
|
2
|
-
/**
|
|
3
|
-
* A function that takes a folder path and returns names of the
|
|
4
|
-
* files insider that folder.
|
|
5
|
-
*/
|
|
6
|
-
export declare type ReadDir = (migrationFolderPath: string) => Promise<string[]>;
|
|
7
|
-
/**
|
|
8
|
-
* A function that combines two file path parts into a single file path.
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* joinPath('/some/path', 'file.ts')
|
|
12
|
-
* // ==> '/some/path/file.ts'
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare type JoinPath = (part1: string, part2: string) => string;
|
|
16
2
|
/**
|
|
17
3
|
* Reads all migrations from a folder.
|
|
18
4
|
*
|
|
19
|
-
* You need to provide a function for reading files in a folder and a function for
|
|
20
|
-
* joining file paths together. The API is like this to make Kysely independent of
|
|
21
|
-
* node.js or any other environment. See the example usage on node.js below.
|
|
22
|
-
*
|
|
23
5
|
* ### Examples
|
|
24
6
|
*
|
|
25
7
|
* ```ts
|
|
26
|
-
* import * as path from 'path'
|
|
27
|
-
* import * as fs from 'fs/promises'
|
|
28
|
-
*
|
|
29
8
|
* new FileMigrationProvider(
|
|
30
|
-
*
|
|
31
|
-
* path.join,
|
|
32
|
-
* path.join(__dirname, 'migrations')
|
|
9
|
+
* 'path/to/migrations/folder'
|
|
33
10
|
* )
|
|
34
11
|
* ```
|
|
35
12
|
*/
|
|
36
13
|
export declare class FileMigrationProvider implements MigrationProvider {
|
|
37
14
|
#private;
|
|
38
|
-
constructor(
|
|
15
|
+
constructor(migrationFolderPath: string);
|
|
39
16
|
/**
|
|
40
17
|
* Returns all migrations, old and new.
|
|
41
18
|
*
|
|
@@ -5,39 +5,30 @@ const object_utils_js_1 = require("../util/object-utils.js");
|
|
|
5
5
|
/**
|
|
6
6
|
* Reads all migrations from a folder.
|
|
7
7
|
*
|
|
8
|
-
* You need to provide a function for reading files in a folder and a function for
|
|
9
|
-
* joining file paths together. The API is like this to make Kysely independent of
|
|
10
|
-
* node.js or any other environment. See the example usage on node.js below.
|
|
11
|
-
*
|
|
12
8
|
* ### Examples
|
|
13
9
|
*
|
|
14
10
|
* ```ts
|
|
15
|
-
* import * as path from 'path'
|
|
16
|
-
* import * as fs from 'fs/promises'
|
|
17
|
-
*
|
|
18
11
|
* new FileMigrationProvider(
|
|
19
|
-
*
|
|
20
|
-
* path.join,
|
|
21
|
-
* path.join(__dirname, 'migrations')
|
|
12
|
+
* 'path/to/migrations/folder'
|
|
22
13
|
* )
|
|
23
14
|
* ```
|
|
24
15
|
*/
|
|
25
16
|
class FileMigrationProvider {
|
|
26
|
-
#readDir;
|
|
27
|
-
#joinPath;
|
|
28
17
|
#migrationFolderPath;
|
|
29
|
-
constructor(
|
|
30
|
-
this.#readDir = readDir;
|
|
31
|
-
this.#joinPath = joinPath;
|
|
18
|
+
constructor(migrationFolderPath) {
|
|
32
19
|
this.#migrationFolderPath = migrationFolderPath;
|
|
33
20
|
}
|
|
34
21
|
async getMigrations() {
|
|
22
|
+
// Import these dynamically so that we don't have any top level
|
|
23
|
+
// node dependencies.
|
|
24
|
+
const fs = await Promise.resolve().then(() => require('fs/promises'));
|
|
25
|
+
const path = await Promise.resolve().then(() => require('path'));
|
|
35
26
|
const migrations = {};
|
|
36
|
-
const files = await
|
|
27
|
+
const files = await fs.readdir(this.#migrationFolderPath);
|
|
37
28
|
for (const fileName of files) {
|
|
38
29
|
if ((fileName.endsWith('.js') || fileName.endsWith('.ts')) &&
|
|
39
30
|
!fileName.endsWith('.d.ts')) {
|
|
40
|
-
const migration = await Promise.resolve().then(() => require(
|
|
31
|
+
const migration = await Promise.resolve().then(() => require(path.join(this.#migrationFolderPath, fileName)));
|
|
41
32
|
if (isMigration(migration)) {
|
|
42
33
|
migrations[fileName.substring(0, fileName.length - 3)] = migration;
|
|
43
34
|
}
|
|
@@ -26,14 +26,9 @@ export interface Migration {
|
|
|
26
26
|
* ```ts
|
|
27
27
|
* const migrator = new Migrator({
|
|
28
28
|
* db,
|
|
29
|
-
* // The constructor signature of FileMigrationProvider is a
|
|
30
|
-
* // bit weird to keep Kysely independent of node.js or any
|
|
31
|
-
* // other environment.
|
|
32
29
|
* provider: new FileMigrationProvider(
|
|
33
|
-
* fs.readdir,
|
|
34
|
-
* path.join,
|
|
35
30
|
* // Path to the folder that contains all your migrations.
|
|
36
|
-
* 'migrations'
|
|
31
|
+
* 'some/path/to/migrations'
|
|
37
32
|
* )
|
|
38
33
|
* })
|
|
39
34
|
* ```
|
|
@@ -57,9 +52,6 @@ export declare class Migrator {
|
|
|
57
52
|
* ### Examples
|
|
58
53
|
*
|
|
59
54
|
* ```ts
|
|
60
|
-
* import * as path from 'path'
|
|
61
|
-
* import * as fs from 'fs/promises'
|
|
62
|
-
*
|
|
63
55
|
* const db = new Kysely<Database>({
|
|
64
56
|
* dialect: new PostgresDialect({
|
|
65
57
|
* host: 'localhost',
|
|
@@ -69,14 +61,9 @@ export declare class Migrator {
|
|
|
69
61
|
*
|
|
70
62
|
* const migrator = new Migrator({
|
|
71
63
|
* db,
|
|
72
|
-
* // The constructor signature of FileMigrationProvider is a
|
|
73
|
-
* // bit weird to keep Kysely independent of node.js or any
|
|
74
|
-
* // other environment.
|
|
75
64
|
* provider: new FileMigrationProvider(
|
|
76
|
-
* fs.readdir,
|
|
77
|
-
* path.join,
|
|
78
65
|
* // Path to the folder that contains all your migrations.
|
|
79
|
-
* 'migrations'
|
|
66
|
+
* 'some/path/to/migrations'
|
|
80
67
|
* )
|
|
81
68
|
* })
|
|
82
69
|
*
|
|
@@ -20,14 +20,9 @@ exports.NO_MIGRATIONS = (0, object_utils_js_1.freeze)({ __noMigrations__: true }
|
|
|
20
20
|
* ```ts
|
|
21
21
|
* const migrator = new Migrator({
|
|
22
22
|
* db,
|
|
23
|
-
* // The constructor signature of FileMigrationProvider is a
|
|
24
|
-
* // bit weird to keep Kysely independent of node.js or any
|
|
25
|
-
* // other environment.
|
|
26
23
|
* provider: new FileMigrationProvider(
|
|
27
|
-
* fs.readdir,
|
|
28
|
-
* path.join,
|
|
29
24
|
* // Path to the folder that contains all your migrations.
|
|
30
|
-
* 'migrations'
|
|
25
|
+
* 'some/path/to/migrations'
|
|
31
26
|
* )
|
|
32
27
|
* })
|
|
33
28
|
* ```
|
|
@@ -53,9 +48,6 @@ class Migrator {
|
|
|
53
48
|
* ### Examples
|
|
54
49
|
*
|
|
55
50
|
* ```ts
|
|
56
|
-
* import * as path from 'path'
|
|
57
|
-
* import * as fs from 'fs/promises'
|
|
58
|
-
*
|
|
59
51
|
* const db = new Kysely<Database>({
|
|
60
52
|
* dialect: new PostgresDialect({
|
|
61
53
|
* host: 'localhost',
|
|
@@ -65,14 +57,9 @@ class Migrator {
|
|
|
65
57
|
*
|
|
66
58
|
* const migrator = new Migrator({
|
|
67
59
|
* db,
|
|
68
|
-
* // The constructor signature of FileMigrationProvider is a
|
|
69
|
-
* // bit weird to keep Kysely independent of node.js or any
|
|
70
|
-
* // other environment.
|
|
71
60
|
* provider: new FileMigrationProvider(
|
|
72
|
-
* fs.readdir,
|
|
73
|
-
* path.join,
|
|
74
61
|
* // Path to the folder that contains all your migrations.
|
|
75
|
-
* 'migrations'
|
|
62
|
+
* 'some/path/to/migrations'
|
|
76
63
|
* )
|
|
77
64
|
* })
|
|
78
65
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CheckConstraintNode } from
|
|
2
|
-
import { ForeignKeyConstraintNode } from
|
|
3
|
-
import { PrimaryKeyConstraintNode } from
|
|
4
|
-
import { UniqueConstraintNode } from
|
|
1
|
+
import { CheckConstraintNode } from './check-constraint-node.js';
|
|
2
|
+
import { ForeignKeyConstraintNode } from './foreign-key-constraint-node.js';
|
|
3
|
+
import { PrimaryKeyConstraintNode } from './primary-constraint-node.js';
|
|
4
|
+
import { UniqueConstraintNode } from './unique-constraint-node.js';
|
|
5
5
|
export declare type ConstraintNode = PrimaryKeyConstraintNode | UniqueConstraintNode | CheckConstraintNode | ForeignKeyConstraintNode;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { JoinNode, JoinType } from '../operation-node/join-node.js';
|
|
2
2
|
import { AnyColumn, AnyColumnWithTable } from '../util/type-utils.js';
|
|
3
|
-
import {
|
|
3
|
+
import { TableExpressionDatabase, TableExpressionTables } from './table-parser.js';
|
|
4
4
|
import { JoinBuilder } from '../query-builder/join-builder.js';
|
|
5
5
|
import { ParseContext } from './parse-context.js';
|
|
6
6
|
export declare type JoinReferenceExpression<DB, TB extends keyof DB, TE> = AnyJoinColumn<DB, TB, TE> | AnyJoinColumnWithTable<DB, TB, TE>;
|
|
7
|
-
export declare type JoinCallbackExpression<DB, TB extends keyof DB, TE> = (join: JoinBuilder<TableExpressionDatabase<DB, TE>,
|
|
8
|
-
declare type AnyJoinColumn<DB, TB extends keyof DB, TE> = AnyColumn<TableExpressionDatabase<DB, TE>,
|
|
9
|
-
declare type AnyJoinColumnWithTable<DB, TB extends keyof DB, TE> = AnyColumnWithTable<TableExpressionDatabase<DB, TE>,
|
|
7
|
+
export declare type JoinCallbackExpression<DB, TB extends keyof DB, TE> = (join: JoinBuilder<TableExpressionDatabase<DB, TE>, TableExpressionTables<DB, TB, TE>>) => JoinBuilder<any, any>;
|
|
8
|
+
declare type AnyJoinColumn<DB, TB extends keyof DB, TE> = AnyColumn<TableExpressionDatabase<DB, TE>, TableExpressionTables<DB, TB, TE>>;
|
|
9
|
+
declare type AnyJoinColumnWithTable<DB, TB extends keyof DB, TE> = AnyColumnWithTable<TableExpressionDatabase<DB, TE>, TableExpressionTables<DB, TB, TE>>;
|
|
10
10
|
export declare function parseJoin(ctx: ParseContext, joinType: JoinType, args: any[]): JoinNode;
|
|
11
11
|
export {};
|
|
@@ -111,5 +111,5 @@ class CamelCasePlugin {
|
|
|
111
111
|
}
|
|
112
112
|
exports.CamelCasePlugin = CamelCasePlugin;
|
|
113
113
|
function canMap(obj) {
|
|
114
|
-
return (0, object_utils_js_1.isObject)(obj) && !(
|
|
114
|
+
return (0, object_utils_js_1.isObject)(obj) && !(0, object_utils_js_1.isDate)(obj) && !(0, object_utils_js_1.isBuffer)(obj);
|
|
115
115
|
}
|
|
@@ -473,13 +473,13 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
473
473
|
* and "pet"."name" = $1
|
|
474
474
|
* ```
|
|
475
475
|
*
|
|
476
|
-
* You can join a subquery by providing a
|
|
477
|
-
* argument:
|
|
476
|
+
* You can join a subquery by providing a select query (or a callback)
|
|
477
|
+
* as the first argument:
|
|
478
478
|
*
|
|
479
479
|
* ```ts
|
|
480
480
|
* await db.selectFrom('person')
|
|
481
481
|
* .innerJoin(
|
|
482
|
-
*
|
|
482
|
+
* qb.selectFrom('pet')
|
|
483
483
|
* .select(['owner_id', 'name'])
|
|
484
484
|
* .where('name', '=', 'Doggo')
|
|
485
485
|
* .as('doggos'),
|
|
@@ -80,13 +80,13 @@ export interface JoinInterface<DB, TB extends keyof DB> {
|
|
|
80
80
|
* and "pet"."name" = $1
|
|
81
81
|
* ```
|
|
82
82
|
*
|
|
83
|
-
* You can join a subquery by providing a
|
|
84
|
-
* argument:
|
|
83
|
+
* You can join a subquery by providing a select query (or a callback)
|
|
84
|
+
* as the first argument:
|
|
85
85
|
*
|
|
86
86
|
* ```ts
|
|
87
87
|
* await db.selectFrom('person')
|
|
88
88
|
* .innerJoin(
|
|
89
|
-
*
|
|
89
|
+
* qb.selectFrom('pet')
|
|
90
90
|
* .select(['owner_id', 'name'])
|
|
91
91
|
* .where('name', '=', 'Doggo')
|
|
92
92
|
* .as('doggos'),
|
|
@@ -811,13 +811,13 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
811
811
|
* and "pet"."name" = $1
|
|
812
812
|
* ```
|
|
813
813
|
*
|
|
814
|
-
* You can join a subquery by providing a
|
|
815
|
-
* argument:
|
|
814
|
+
* You can join a subquery by providing a select query (or a callback)
|
|
815
|
+
* as the first argument:
|
|
816
816
|
*
|
|
817
817
|
* ```ts
|
|
818
818
|
* await db.selectFrom('person')
|
|
819
819
|
* .innerJoin(
|
|
820
|
-
*
|
|
820
|
+
* qb.selectFrom('pet')
|
|
821
821
|
* .select(['owner_id', 'name'])
|
|
822
822
|
* .where('name', '=', 'Doggo')
|
|
823
823
|
* .as('doggos'),
|
|
@@ -474,13 +474,13 @@ export declare class UpdateQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
474
474
|
* and "pet"."name" = $1
|
|
475
475
|
* ```
|
|
476
476
|
*
|
|
477
|
-
* You can join a subquery by providing a
|
|
478
|
-
* argument:
|
|
477
|
+
* You can join a subquery by providing a select query (or a callback)
|
|
478
|
+
* as the first argument:
|
|
479
479
|
*
|
|
480
480
|
* ```ts
|
|
481
481
|
* await db.selectFrom('person')
|
|
482
482
|
* .innerJoin(
|
|
483
|
-
*
|
|
483
|
+
* qb.selectFrom('pet')
|
|
484
484
|
* .select(['owner_id', 'name'])
|
|
485
485
|
* .where('name', '=', 'Doggo')
|
|
486
486
|
* .as('doggos'),
|
|
@@ -6,8 +6,8 @@ export declare function isNumber(obj: unknown): obj is number;
|
|
|
6
6
|
export declare function isBoolean(obj: unknown): obj is boolean;
|
|
7
7
|
export declare function isNull(obj: unknown): obj is null;
|
|
8
8
|
export declare function isDate(obj: unknown): obj is Date;
|
|
9
|
-
export declare function isBuffer(obj: unknown): obj is Buffer;
|
|
10
9
|
export declare function isBigInt(obj: unknown): obj is BigInt;
|
|
10
|
+
export declare function isBuffer(obj: unknown): obj is Buffer;
|
|
11
11
|
export declare function isPrimitive(obj: unknown): obj is PrimitiveValue;
|
|
12
12
|
export declare function isFunction(obj: unknown): obj is Function;
|
|
13
13
|
export declare function isObject(obj: unknown): obj is Record<string, unknown>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.noop = exports.isReadonlyArray = exports.asReadonlyArray = exports.asArray = exports.freeze = exports.getLast = exports.isObject = exports.isFunction = exports.isPrimitive = exports.
|
|
3
|
+
exports.noop = exports.isReadonlyArray = exports.asReadonlyArray = exports.asArray = exports.freeze = exports.getLast = exports.isObject = exports.isFunction = exports.isPrimitive = exports.isBuffer = exports.isBigInt = exports.isDate = exports.isNull = exports.isBoolean = exports.isNumber = exports.isString = exports.isEmpty = void 0;
|
|
4
4
|
function isEmpty(obj) {
|
|
5
|
-
if (Array.isArray(obj) || isString(obj) ||
|
|
5
|
+
if (Array.isArray(obj) || isString(obj) || isBuffer(obj)) {
|
|
6
6
|
return obj.length === 0;
|
|
7
7
|
}
|
|
8
8
|
else if (obj) {
|
|
@@ -31,22 +31,22 @@ function isDate(obj) {
|
|
|
31
31
|
return obj instanceof Date;
|
|
32
32
|
}
|
|
33
33
|
exports.isDate = isDate;
|
|
34
|
-
function isBuffer(obj) {
|
|
35
|
-
return Buffer.isBuffer(obj);
|
|
36
|
-
}
|
|
37
|
-
exports.isBuffer = isBuffer;
|
|
38
34
|
function isBigInt(obj) {
|
|
39
35
|
return typeof obj === 'bigint';
|
|
40
36
|
}
|
|
41
37
|
exports.isBigInt = isBigInt;
|
|
38
|
+
function isBuffer(obj) {
|
|
39
|
+
return typeof Buffer !== 'undefined' && Buffer.isBuffer(obj);
|
|
40
|
+
}
|
|
41
|
+
exports.isBuffer = isBuffer;
|
|
42
42
|
function isPrimitive(obj) {
|
|
43
43
|
return (isString(obj) ||
|
|
44
44
|
isNumber(obj) ||
|
|
45
45
|
isBoolean(obj) ||
|
|
46
46
|
isNull(obj) ||
|
|
47
47
|
isDate(obj) ||
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
isBigInt(obj) ||
|
|
49
|
+
isBuffer(obj));
|
|
50
50
|
}
|
|
51
51
|
exports.isPrimitive = isPrimitive;
|
|
52
52
|
function isFunction(obj) {
|
|
@@ -4,7 +4,7 @@ import { ColumnDataType } from '../operation-node/data-type-node.js';
|
|
|
4
4
|
*/
|
|
5
5
|
export interface DatabaseIntrospector {
|
|
6
6
|
/**
|
|
7
|
-
* Get the database metadata such as
|
|
7
|
+
* Get the database metadata such as table and column names.
|
|
8
8
|
*/
|
|
9
9
|
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
10
10
|
}
|
|
@@ -20,7 +20,7 @@ export declare abstract class DialectAdapterBase implements DialectAdapter {
|
|
|
20
20
|
get supportsReturning(): boolean;
|
|
21
21
|
/**
|
|
22
22
|
* This method is used to acquire a lock for the migrations so that
|
|
23
|
-
* it's not possible for two migration
|
|
23
|
+
* it's not possible for two migration operations to run in parallel.
|
|
24
24
|
*
|
|
25
25
|
* Most dialects have explicit locks that can be used, like advisory locks
|
|
26
26
|
* in PostgreSQL and the get_lock function in MySQL.
|
|
@@ -21,7 +21,7 @@ export interface DialectAdapter {
|
|
|
21
21
|
readonly supportsReturning: boolean;
|
|
22
22
|
/**
|
|
23
23
|
* This method is used to acquire a lock for the migrations so that
|
|
24
|
-
* it's not possible for two migration
|
|
24
|
+
* it's not possible for two migration operations to run in parallel.
|
|
25
25
|
*
|
|
26
26
|
* Most dialects have explicit locks that can be used, like advisory locks
|
|
27
27
|
* in PostgreSQL and the get_lock function in MySQL.
|
|
@@ -24,8 +24,8 @@ export interface Dialect {
|
|
|
24
24
|
*/
|
|
25
25
|
createAdapter(): DialectAdapter;
|
|
26
26
|
/**
|
|
27
|
-
* Creates a database introspector that can be used to get
|
|
28
|
-
* such as the
|
|
27
|
+
* Creates a database introspector that can be used to get database metadata
|
|
28
|
+
* such as the table names and column names of those tables.
|
|
29
29
|
*
|
|
30
30
|
* `db` never has any plugins installed. It's created using
|
|
31
31
|
* {@link Kysely.withoutPlugins}.
|
|
@@ -14,7 +14,7 @@ export declare class MysqlAdapter extends DialectAdapterBase {
|
|
|
14
14
|
get supportsReturning(): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* This method is used to acquire a lock for the migrations so that
|
|
17
|
-
* it's not possible for two migration
|
|
17
|
+
* it's not possible for two migration operations to run in parallel.
|
|
18
18
|
*
|
|
19
19
|
* Most dialects have explicit locks that can be used, like advisory locks
|
|
20
20
|
* in PostgreSQL and the get_lock function in MySQL.
|
|
@@ -28,8 +28,8 @@ export declare class MysqlDialect implements Dialect {
|
|
|
28
28
|
*/
|
|
29
29
|
createAdapter(): DialectAdapter;
|
|
30
30
|
/**
|
|
31
|
-
* Creates a database introspector that can be used to get
|
|
32
|
-
* such as the
|
|
31
|
+
* Creates a database introspector that can be used to get database metadata
|
|
32
|
+
* such as the table names and column names of those tables.
|
|
33
33
|
*
|
|
34
34
|
* `db` never has any plugins installed. It's created using
|
|
35
35
|
* {@link Kysely.withoutPlugins}.
|
|
@@ -4,7 +4,7 @@ export declare class MysqlIntrospector implements DatabaseIntrospector {
|
|
|
4
4
|
#private;
|
|
5
5
|
constructor(db: Kysely<any>);
|
|
6
6
|
/**
|
|
7
|
-
* Get the database metadata such as
|
|
7
|
+
* Get the database metadata such as table and column names.
|
|
8
8
|
*/
|
|
9
9
|
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
10
10
|
}
|
|
@@ -14,7 +14,7 @@ export declare class PostgresAdapter extends DialectAdapterBase {
|
|
|
14
14
|
get supportsReturning(): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* This method is used to acquire a lock for the migrations so that
|
|
17
|
-
* it's not possible for two migration
|
|
17
|
+
* it's not possible for two migration operations to run in parallel.
|
|
18
18
|
*
|
|
19
19
|
* Most dialects have explicit locks that can be used, like advisory locks
|
|
20
20
|
* in PostgreSQL and the get_lock function in MySQL.
|
|
@@ -34,8 +34,8 @@ export declare class PostgresDialect implements Dialect {
|
|
|
34
34
|
*/
|
|
35
35
|
createAdapter(): DialectAdapter;
|
|
36
36
|
/**
|
|
37
|
-
* Creates a database introspector that can be used to get
|
|
38
|
-
* such as the
|
|
37
|
+
* Creates a database introspector that can be used to get database metadata
|
|
38
|
+
* such as the table names and column names of those tables.
|
|
39
39
|
*
|
|
40
40
|
* `db` never has any plugins installed. It's created using
|
|
41
41
|
* {@link Kysely.withoutPlugins}.
|
|
@@ -4,7 +4,7 @@ export declare class PostgresIntrospector implements DatabaseIntrospector {
|
|
|
4
4
|
#private;
|
|
5
5
|
constructor(db: Kysely<any>);
|
|
6
6
|
/**
|
|
7
|
-
* Get the database metadata such as
|
|
7
|
+
* Get the database metadata such as table and column names.
|
|
8
8
|
*/
|
|
9
9
|
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
10
10
|
}
|
|
@@ -13,7 +13,7 @@ export declare class SqliteAdapter implements DialectAdapterBase {
|
|
|
13
13
|
get supportsReturning(): boolean;
|
|
14
14
|
/**
|
|
15
15
|
* This method is used to acquire a lock for the migrations so that
|
|
16
|
-
* it's not possible for two migration
|
|
16
|
+
* it's not possible for two migration operations to run in parallel.
|
|
17
17
|
*
|
|
18
18
|
* Most dialects have explicit locks that can be used, like advisory locks
|
|
19
19
|
* in PostgreSQL and the get_lock function in MySQL.
|
|
@@ -28,8 +28,8 @@ export declare class SqliteDialect implements Dialect {
|
|
|
28
28
|
*/
|
|
29
29
|
createAdapter(): DialectAdapter;
|
|
30
30
|
/**
|
|
31
|
-
* Creates a database introspector that can be used to get
|
|
32
|
-
* such as the
|
|
31
|
+
* Creates a database introspector that can be used to get database metadata
|
|
32
|
+
* such as the table names and column names of those tables.
|
|
33
33
|
*
|
|
34
34
|
* `db` never has any plugins installed. It's created using
|
|
35
35
|
* {@link Kysely.withoutPlugins}.
|
|
@@ -4,7 +4,7 @@ export declare class SqliteIntrospector implements DatabaseIntrospector {
|
|
|
4
4
|
#private;
|
|
5
5
|
constructor(db: Kysely<any>);
|
|
6
6
|
/**
|
|
7
|
-
* Get the database metadata such as
|
|
7
|
+
* Get the database metadata such as table and column names.
|
|
8
8
|
*/
|
|
9
9
|
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
10
10
|
}
|
package/dist/esm/kysely.js
CHANGED
|
@@ -56,9 +56,11 @@ import { PRIVATE_ADAPTER } from './util/private-symbols.js';
|
|
|
56
56
|
export class Kysely extends QueryCreator {
|
|
57
57
|
#props;
|
|
58
58
|
constructor(args) {
|
|
59
|
+
let superProps;
|
|
60
|
+
let props;
|
|
59
61
|
if (isKyselyProps(args)) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
superProps = { executor: args.executor, parseContext: args.parseContext };
|
|
63
|
+
props = { ...args };
|
|
62
64
|
}
|
|
63
65
|
else {
|
|
64
66
|
const dialect = args.dialect;
|
|
@@ -70,15 +72,17 @@ export class Kysely extends QueryCreator {
|
|
|
70
72
|
const runtimeDriver = new RuntimeDriver(driver, log);
|
|
71
73
|
const connectionProvider = new DefaultConnectionProvider(runtimeDriver);
|
|
72
74
|
const executor = new DefaultQueryExecutor(compiler, connectionProvider, args.plugins ?? []);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
superProps = { executor, parseContext };
|
|
76
|
+
props = {
|
|
75
77
|
config: args,
|
|
76
78
|
executor,
|
|
77
79
|
dialect,
|
|
78
80
|
driver: runtimeDriver,
|
|
79
81
|
parseContext,
|
|
80
|
-
}
|
|
82
|
+
};
|
|
81
83
|
}
|
|
84
|
+
super(superProps);
|
|
85
|
+
this.#props = freeze(props);
|
|
82
86
|
}
|
|
83
87
|
/**
|
|
84
88
|
* Returns the {@link SchemaModule} module for building database schema.
|
|
@@ -1,41 +1,18 @@
|
|
|
1
1
|
import { Migration, MigrationProvider } from './migrator.js';
|
|
2
|
-
/**
|
|
3
|
-
* A function that takes a folder path and returns names of the
|
|
4
|
-
* files insider that folder.
|
|
5
|
-
*/
|
|
6
|
-
export declare type ReadDir = (migrationFolderPath: string) => Promise<string[]>;
|
|
7
|
-
/**
|
|
8
|
-
* A function that combines two file path parts into a single file path.
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* joinPath('/some/path', 'file.ts')
|
|
12
|
-
* // ==> '/some/path/file.ts'
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare type JoinPath = (part1: string, part2: string) => string;
|
|
16
2
|
/**
|
|
17
3
|
* Reads all migrations from a folder.
|
|
18
4
|
*
|
|
19
|
-
* You need to provide a function for reading files in a folder and a function for
|
|
20
|
-
* joining file paths together. The API is like this to make Kysely independent of
|
|
21
|
-
* node.js or any other environment. See the example usage on node.js below.
|
|
22
|
-
*
|
|
23
5
|
* ### Examples
|
|
24
6
|
*
|
|
25
7
|
* ```ts
|
|
26
|
-
* import * as path from 'path'
|
|
27
|
-
* import * as fs from 'fs/promises'
|
|
28
|
-
*
|
|
29
8
|
* new FileMigrationProvider(
|
|
30
|
-
*
|
|
31
|
-
* path.join,
|
|
32
|
-
* path.join(__dirname, 'migrations')
|
|
9
|
+
* 'path/to/migrations/folder'
|
|
33
10
|
* )
|
|
34
11
|
* ```
|
|
35
12
|
*/
|
|
36
13
|
export declare class FileMigrationProvider implements MigrationProvider {
|
|
37
14
|
#private;
|
|
38
|
-
constructor(
|
|
15
|
+
constructor(migrationFolderPath: string);
|
|
39
16
|
/**
|
|
40
17
|
* Returns all migrations, old and new.
|
|
41
18
|
*
|
|
@@ -2,39 +2,30 @@ import { isFunction, isObject } from '../util/object-utils.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Reads all migrations from a folder.
|
|
4
4
|
*
|
|
5
|
-
* You need to provide a function for reading files in a folder and a function for
|
|
6
|
-
* joining file paths together. The API is like this to make Kysely independent of
|
|
7
|
-
* node.js or any other environment. See the example usage on node.js below.
|
|
8
|
-
*
|
|
9
5
|
* ### Examples
|
|
10
6
|
*
|
|
11
7
|
* ```ts
|
|
12
|
-
* import * as path from 'path'
|
|
13
|
-
* import * as fs from 'fs/promises'
|
|
14
|
-
*
|
|
15
8
|
* new FileMigrationProvider(
|
|
16
|
-
*
|
|
17
|
-
* path.join,
|
|
18
|
-
* path.join(__dirname, 'migrations')
|
|
9
|
+
* 'path/to/migrations/folder'
|
|
19
10
|
* )
|
|
20
11
|
* ```
|
|
21
12
|
*/
|
|
22
13
|
export class FileMigrationProvider {
|
|
23
|
-
#readDir;
|
|
24
|
-
#joinPath;
|
|
25
14
|
#migrationFolderPath;
|
|
26
|
-
constructor(
|
|
27
|
-
this.#readDir = readDir;
|
|
28
|
-
this.#joinPath = joinPath;
|
|
15
|
+
constructor(migrationFolderPath) {
|
|
29
16
|
this.#migrationFolderPath = migrationFolderPath;
|
|
30
17
|
}
|
|
31
18
|
async getMigrations() {
|
|
19
|
+
// Import these dynamically so that we don't have any top level
|
|
20
|
+
// node dependencies.
|
|
21
|
+
const fs = await import('fs/promises');
|
|
22
|
+
const path = await import('path');
|
|
32
23
|
const migrations = {};
|
|
33
|
-
const files = await
|
|
24
|
+
const files = await fs.readdir(this.#migrationFolderPath);
|
|
34
25
|
for (const fileName of files) {
|
|
35
26
|
if ((fileName.endsWith('.js') || fileName.endsWith('.ts')) &&
|
|
36
27
|
!fileName.endsWith('.d.ts')) {
|
|
37
|
-
const migration = await import(
|
|
28
|
+
const migration = await import(path.join(this.#migrationFolderPath, fileName));
|
|
38
29
|
if (isMigration(migration)) {
|
|
39
30
|
migrations[fileName.substring(0, fileName.length - 3)] = migration;
|
|
40
31
|
}
|
|
@@ -26,14 +26,9 @@ export interface Migration {
|
|
|
26
26
|
* ```ts
|
|
27
27
|
* const migrator = new Migrator({
|
|
28
28
|
* db,
|
|
29
|
-
* // The constructor signature of FileMigrationProvider is a
|
|
30
|
-
* // bit weird to keep Kysely independent of node.js or any
|
|
31
|
-
* // other environment.
|
|
32
29
|
* provider: new FileMigrationProvider(
|
|
33
|
-
* fs.readdir,
|
|
34
|
-
* path.join,
|
|
35
30
|
* // Path to the folder that contains all your migrations.
|
|
36
|
-
* 'migrations'
|
|
31
|
+
* 'some/path/to/migrations'
|
|
37
32
|
* )
|
|
38
33
|
* })
|
|
39
34
|
* ```
|
|
@@ -57,9 +52,6 @@ export declare class Migrator {
|
|
|
57
52
|
* ### Examples
|
|
58
53
|
*
|
|
59
54
|
* ```ts
|
|
60
|
-
* import * as path from 'path'
|
|
61
|
-
* import * as fs from 'fs/promises'
|
|
62
|
-
*
|
|
63
55
|
* const db = new Kysely<Database>({
|
|
64
56
|
* dialect: new PostgresDialect({
|
|
65
57
|
* host: 'localhost',
|
|
@@ -69,14 +61,9 @@ export declare class Migrator {
|
|
|
69
61
|
*
|
|
70
62
|
* const migrator = new Migrator({
|
|
71
63
|
* db,
|
|
72
|
-
* // The constructor signature of FileMigrationProvider is a
|
|
73
|
-
* // bit weird to keep Kysely independent of node.js or any
|
|
74
|
-
* // other environment.
|
|
75
64
|
* provider: new FileMigrationProvider(
|
|
76
|
-
* fs.readdir,
|
|
77
|
-
* path.join,
|
|
78
65
|
* // Path to the folder that contains all your migrations.
|
|
79
|
-
* 'migrations'
|
|
66
|
+
* 'some/path/to/migrations'
|
|
80
67
|
* )
|
|
81
68
|
* })
|
|
82
69
|
*
|
|
@@ -17,14 +17,9 @@ export const NO_MIGRATIONS = freeze({ __noMigrations__: true });
|
|
|
17
17
|
* ```ts
|
|
18
18
|
* const migrator = new Migrator({
|
|
19
19
|
* db,
|
|
20
|
-
* // The constructor signature of FileMigrationProvider is a
|
|
21
|
-
* // bit weird to keep Kysely independent of node.js or any
|
|
22
|
-
* // other environment.
|
|
23
20
|
* provider: new FileMigrationProvider(
|
|
24
|
-
* fs.readdir,
|
|
25
|
-
* path.join,
|
|
26
21
|
* // Path to the folder that contains all your migrations.
|
|
27
|
-
* 'migrations'
|
|
22
|
+
* 'some/path/to/migrations'
|
|
28
23
|
* )
|
|
29
24
|
* })
|
|
30
25
|
* ```
|
|
@@ -50,9 +45,6 @@ export class Migrator {
|
|
|
50
45
|
* ### Examples
|
|
51
46
|
*
|
|
52
47
|
* ```ts
|
|
53
|
-
* import * as path from 'path'
|
|
54
|
-
* import * as fs from 'fs/promises'
|
|
55
|
-
*
|
|
56
48
|
* const db = new Kysely<Database>({
|
|
57
49
|
* dialect: new PostgresDialect({
|
|
58
50
|
* host: 'localhost',
|
|
@@ -62,14 +54,9 @@ export class Migrator {
|
|
|
62
54
|
*
|
|
63
55
|
* const migrator = new Migrator({
|
|
64
56
|
* db,
|
|
65
|
-
* // The constructor signature of FileMigrationProvider is a
|
|
66
|
-
* // bit weird to keep Kysely independent of node.js or any
|
|
67
|
-
* // other environment.
|
|
68
57
|
* provider: new FileMigrationProvider(
|
|
69
|
-
* fs.readdir,
|
|
70
|
-
* path.join,
|
|
71
58
|
* // Path to the folder that contains all your migrations.
|
|
72
|
-
* 'migrations'
|
|
59
|
+
* 'some/path/to/migrations'
|
|
73
60
|
* )
|
|
74
61
|
* })
|
|
75
62
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CheckConstraintNode } from
|
|
2
|
-
import { ForeignKeyConstraintNode } from
|
|
3
|
-
import { PrimaryKeyConstraintNode } from
|
|
4
|
-
import { UniqueConstraintNode } from
|
|
1
|
+
import { CheckConstraintNode } from './check-constraint-node.js';
|
|
2
|
+
import { ForeignKeyConstraintNode } from './foreign-key-constraint-node.js';
|
|
3
|
+
import { PrimaryKeyConstraintNode } from './primary-constraint-node.js';
|
|
4
|
+
import { UniqueConstraintNode } from './unique-constraint-node.js';
|
|
5
5
|
export declare type ConstraintNode = PrimaryKeyConstraintNode | UniqueConstraintNode | CheckConstraintNode | ForeignKeyConstraintNode;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { JoinNode, JoinType } from '../operation-node/join-node.js';
|
|
2
2
|
import { AnyColumn, AnyColumnWithTable } from '../util/type-utils.js';
|
|
3
|
-
import {
|
|
3
|
+
import { TableExpressionDatabase, TableExpressionTables } from './table-parser.js';
|
|
4
4
|
import { JoinBuilder } from '../query-builder/join-builder.js';
|
|
5
5
|
import { ParseContext } from './parse-context.js';
|
|
6
6
|
export declare type JoinReferenceExpression<DB, TB extends keyof DB, TE> = AnyJoinColumn<DB, TB, TE> | AnyJoinColumnWithTable<DB, TB, TE>;
|
|
7
|
-
export declare type JoinCallbackExpression<DB, TB extends keyof DB, TE> = (join: JoinBuilder<TableExpressionDatabase<DB, TE>,
|
|
8
|
-
declare type AnyJoinColumn<DB, TB extends keyof DB, TE> = AnyColumn<TableExpressionDatabase<DB, TE>,
|
|
9
|
-
declare type AnyJoinColumnWithTable<DB, TB extends keyof DB, TE> = AnyColumnWithTable<TableExpressionDatabase<DB, TE>,
|
|
7
|
+
export declare type JoinCallbackExpression<DB, TB extends keyof DB, TE> = (join: JoinBuilder<TableExpressionDatabase<DB, TE>, TableExpressionTables<DB, TB, TE>>) => JoinBuilder<any, any>;
|
|
8
|
+
declare type AnyJoinColumn<DB, TB extends keyof DB, TE> = AnyColumn<TableExpressionDatabase<DB, TE>, TableExpressionTables<DB, TB, TE>>;
|
|
9
|
+
declare type AnyJoinColumnWithTable<DB, TB extends keyof DB, TE> = AnyColumnWithTable<TableExpressionDatabase<DB, TE>, TableExpressionTables<DB, TB, TE>>;
|
|
10
10
|
export declare function parseJoin(ctx: ParseContext, joinType: JoinType, args: any[]): JoinNode;
|
|
11
11
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isObject } from '../../util/object-utils.js';
|
|
1
|
+
import { isBuffer, isDate, isObject } from '../../util/object-utils.js';
|
|
2
2
|
import { SnakeCaseTransformer } from './camel-case-transformer.js';
|
|
3
3
|
import { createCamelCaseMapper, createSnakeCaseMapper, } from './camel-case.js';
|
|
4
4
|
/**
|
|
@@ -107,5 +107,5 @@ export class CamelCasePlugin {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
function canMap(obj) {
|
|
110
|
-
return isObject(obj) && !(obj
|
|
110
|
+
return isObject(obj) && !isDate(obj) && !isBuffer(obj);
|
|
111
111
|
}
|
|
@@ -473,13 +473,13 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
473
473
|
* and "pet"."name" = $1
|
|
474
474
|
* ```
|
|
475
475
|
*
|
|
476
|
-
* You can join a subquery by providing a
|
|
477
|
-
* argument:
|
|
476
|
+
* You can join a subquery by providing a select query (or a callback)
|
|
477
|
+
* as the first argument:
|
|
478
478
|
*
|
|
479
479
|
* ```ts
|
|
480
480
|
* await db.selectFrom('person')
|
|
481
481
|
* .innerJoin(
|
|
482
|
-
*
|
|
482
|
+
* qb.selectFrom('pet')
|
|
483
483
|
* .select(['owner_id', 'name'])
|
|
484
484
|
* .where('name', '=', 'Doggo')
|
|
485
485
|
* .as('doggos'),
|
|
@@ -80,13 +80,13 @@ export interface JoinInterface<DB, TB extends keyof DB> {
|
|
|
80
80
|
* and "pet"."name" = $1
|
|
81
81
|
* ```
|
|
82
82
|
*
|
|
83
|
-
* You can join a subquery by providing a
|
|
84
|
-
* argument:
|
|
83
|
+
* You can join a subquery by providing a select query (or a callback)
|
|
84
|
+
* as the first argument:
|
|
85
85
|
*
|
|
86
86
|
* ```ts
|
|
87
87
|
* await db.selectFrom('person')
|
|
88
88
|
* .innerJoin(
|
|
89
|
-
*
|
|
89
|
+
* qb.selectFrom('pet')
|
|
90
90
|
* .select(['owner_id', 'name'])
|
|
91
91
|
* .where('name', '=', 'Doggo')
|
|
92
92
|
* .as('doggos'),
|
|
@@ -811,13 +811,13 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
811
811
|
* and "pet"."name" = $1
|
|
812
812
|
* ```
|
|
813
813
|
*
|
|
814
|
-
* You can join a subquery by providing a
|
|
815
|
-
* argument:
|
|
814
|
+
* You can join a subquery by providing a select query (or a callback)
|
|
815
|
+
* as the first argument:
|
|
816
816
|
*
|
|
817
817
|
* ```ts
|
|
818
818
|
* await db.selectFrom('person')
|
|
819
819
|
* .innerJoin(
|
|
820
|
-
*
|
|
820
|
+
* qb.selectFrom('pet')
|
|
821
821
|
* .select(['owner_id', 'name'])
|
|
822
822
|
* .where('name', '=', 'Doggo')
|
|
823
823
|
* .as('doggos'),
|
|
@@ -474,13 +474,13 @@ export declare class UpdateQueryBuilder<DB, TB extends keyof DB, O> implements W
|
|
|
474
474
|
* and "pet"."name" = $1
|
|
475
475
|
* ```
|
|
476
476
|
*
|
|
477
|
-
* You can join a subquery by providing a
|
|
478
|
-
* argument:
|
|
477
|
+
* You can join a subquery by providing a select query (or a callback)
|
|
478
|
+
* as the first argument:
|
|
479
479
|
*
|
|
480
480
|
* ```ts
|
|
481
481
|
* await db.selectFrom('person')
|
|
482
482
|
* .innerJoin(
|
|
483
|
-
*
|
|
483
|
+
* qb.selectFrom('pet')
|
|
484
484
|
* .select(['owner_id', 'name'])
|
|
485
485
|
* .where('name', '=', 'Doggo')
|
|
486
486
|
* .as('doggos'),
|
|
@@ -6,8 +6,8 @@ export declare function isNumber(obj: unknown): obj is number;
|
|
|
6
6
|
export declare function isBoolean(obj: unknown): obj is boolean;
|
|
7
7
|
export declare function isNull(obj: unknown): obj is null;
|
|
8
8
|
export declare function isDate(obj: unknown): obj is Date;
|
|
9
|
-
export declare function isBuffer(obj: unknown): obj is Buffer;
|
|
10
9
|
export declare function isBigInt(obj: unknown): obj is BigInt;
|
|
10
|
+
export declare function isBuffer(obj: unknown): obj is Buffer;
|
|
11
11
|
export declare function isPrimitive(obj: unknown): obj is PrimitiveValue;
|
|
12
12
|
export declare function isFunction(obj: unknown): obj is Function;
|
|
13
13
|
export declare function isObject(obj: unknown): obj is Record<string, unknown>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function isEmpty(obj) {
|
|
2
|
-
if (Array.isArray(obj) || isString(obj) ||
|
|
2
|
+
if (Array.isArray(obj) || isString(obj) || isBuffer(obj)) {
|
|
3
3
|
return obj.length === 0;
|
|
4
4
|
}
|
|
5
5
|
else if (obj) {
|
|
@@ -22,20 +22,20 @@ export function isNull(obj) {
|
|
|
22
22
|
export function isDate(obj) {
|
|
23
23
|
return obj instanceof Date;
|
|
24
24
|
}
|
|
25
|
-
export function isBuffer(obj) {
|
|
26
|
-
return Buffer.isBuffer(obj);
|
|
27
|
-
}
|
|
28
25
|
export function isBigInt(obj) {
|
|
29
26
|
return typeof obj === 'bigint';
|
|
30
27
|
}
|
|
28
|
+
export function isBuffer(obj) {
|
|
29
|
+
return typeof Buffer !== 'undefined' && Buffer.isBuffer(obj);
|
|
30
|
+
}
|
|
31
31
|
export function isPrimitive(obj) {
|
|
32
32
|
return (isString(obj) ||
|
|
33
33
|
isNumber(obj) ||
|
|
34
34
|
isBoolean(obj) ||
|
|
35
35
|
isNull(obj) ||
|
|
36
36
|
isDate(obj) ||
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
isBigInt(obj) ||
|
|
38
|
+
isBuffer(obj));
|
|
39
39
|
}
|
|
40
40
|
export function isFunction(obj) {
|
|
41
41
|
return typeof obj === 'function';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kysely",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "Type safe SQL query builder",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
".": {
|
|
16
16
|
"import": "./dist/esm/index.js",
|
|
17
17
|
"require": "./dist/cjs/index.js"
|
|
18
|
-
}
|
|
18
|
+
},
|
|
19
|
+
"./dist/cjs/index-nodeless.js": "./dist/cjs/index-nodeless.js",
|
|
20
|
+
"./dist/esm/index-nodeless.js": "./dist/esm/index-nodeless.js"
|
|
19
21
|
},
|
|
20
22
|
"scripts": {
|
|
21
23
|
"test:build": "rm -rf test/dist && tsc -p test",
|
package/test.js
DELETED