@riao/dbal 3.8.0 → 3.8.1
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/CHANGELOG.md +3 -3
- package/LICENSE.md +20 -20
- package/README.md +148 -148
- package/builder/builder.d.ts +7 -7
- package/builder/builder.js +19 -19
- package/builder/index.d.ts +2 -2
- package/builder/index.js +7 -7
- package/builder/sql-builder.d.ts +53 -53
- package/builder/sql-builder.js +157 -157
- package/builder/statement-builder.d.ts +12 -12
- package/builder/statement-builder.js +32 -32
- package/column/column-options.d.ts +156 -156
- package/column/column-options.js +2 -2
- package/column/column-type.d.ts +18 -18
- package/column/column-type.js +27 -27
- package/column/column-values.d.ts +34 -34
- package/column/column-values.js +2 -2
- package/column/index.d.ts +3 -3
- package/column/index.js +19 -19
- package/column-pack/date-time/create-timestamp-column.d.ts +2 -2
- package/column-pack/date-time/create-timestamp-column.js +10 -10
- package/column-pack/date-time/index.d.ts +2 -2
- package/column-pack/date-time/index.js +7 -7
- package/column-pack/date-time/update-timestamp-column.d.ts +2 -2
- package/column-pack/date-time/update-timestamp-column.js +14 -14
- package/column-pack/index.d.ts +6 -6
- package/column-pack/index.js +22 -22
- package/column-pack/keys/big-int-key-column.d.ts +2 -2
- package/column-pack/keys/big-int-key-column.js +10 -10
- package/column-pack/keys/index.d.ts +3 -3
- package/column-pack/keys/index.js +9 -9
- package/column-pack/keys/int-key-column.d.ts +2 -2
- package/column-pack/keys/int-key-column.js +10 -10
- package/column-pack/keys/uuid-key-column.d.ts +2 -2
- package/column-pack/keys/uuid-key-column.js +11 -11
- package/column-pack/person/date-of-birth-column.d.ts +2 -2
- package/column-pack/person/date-of-birth-column.js +8 -8
- package/column-pack/person/first-name-column.d.ts +2 -2
- package/column-pack/person/first-name-column.js +9 -9
- package/column-pack/person/index.d.ts +3 -3
- package/column-pack/person/index.js +9 -9
- package/column-pack/person/last-name-column.d.ts +2 -2
- package/column-pack/person/last-name-column.js +9 -9
- package/column-pack/resource/content-column.d.ts +2 -2
- package/column-pack/resource/content-column.js +9 -9
- package/column-pack/resource/description-column.d.ts +2 -2
- package/column-pack/resource/description-column.js +9 -9
- package/column-pack/resource/index.d.ts +6 -6
- package/column-pack/resource/index.js +15 -15
- package/column-pack/resource/is-active-column.d.ts +2 -2
- package/column-pack/resource/is-active-column.js +9 -9
- package/column-pack/resource/name-column.d.ts +2 -2
- package/column-pack/resource/name-column.js +10 -10
- package/column-pack/resource/path-column.d.ts +2 -2
- package/column-pack/resource/path-column.js +11 -11
- package/column-pack/resource/title-column.d.ts +2 -2
- package/column-pack/resource/title-column.js +10 -10
- package/column-pack/system/filename-column.d.ts +2 -2
- package/column-pack/system/filename-column.js +9 -9
- package/column-pack/system/filepath-column.d.ts +2 -2
- package/column-pack/system/filepath-column.js +9 -9
- package/column-pack/system/index.d.ts +4 -4
- package/column-pack/system/index.js +11 -11
- package/column-pack/system/ip-address-column.d.ts +2 -2
- package/column-pack/system/ip-address-column.js +9 -9
- package/column-pack/system/url-column.d.ts +3 -3
- package/column-pack/system/url-column.js +13 -13
- package/column-pack/user/email-column.d.ts +2 -2
- package/column-pack/user/email-column.js +11 -11
- package/column-pack/user/index.d.ts +4 -4
- package/column-pack/user/index.js +11 -11
- package/column-pack/user/password-column.d.ts +2 -2
- package/column-pack/user/password-column.js +10 -10
- package/column-pack/user/temp-email-column.d.ts +2 -2
- package/column-pack/user/temp-email-column.js +5 -5
- package/column-pack/user/username-column.d.ts +2 -2
- package/column-pack/user/username-column.js +11 -11
- package/comparison/comparison-aliases.d.ts +10 -10
- package/comparison/comparison-aliases.js +40 -40
- package/comparison/comparison-token.d.ts +17 -17
- package/comparison/comparison-token.js +15 -15
- package/comparison/comparison.d.ts +13 -13
- package/comparison/comparison.js +71 -71
- package/comparison/index.d.ts +4 -4
- package/comparison/index.js +24 -24
- package/comparison/is-comparison-token.d.ts +2 -2
- package/comparison/is-comparison-token.js +8 -8
- package/config/configure-db.d.ts +14 -14
- package/config/configure-db.js +18 -18
- package/config/database-env.d.ts +16 -16
- package/config/database-env.js +14 -14
- package/config/index.d.ts +2 -2
- package/config/index.js +7 -7
- package/database/connection-options.d.ts +7 -7
- package/database/connection-options.js +2 -2
- package/database/database.d.ts +204 -204
- package/database/database.js +330 -330
- package/database/driver-query.d.ts +10 -10
- package/database/driver-query.js +2 -2
- package/database/driver.d.ts +12 -12
- package/database/driver.js +47 -47
- package/database/get-database-path.d.ts +6 -6
- package/database/get-database-path.js +12 -12
- package/database/index.d.ts +7 -7
- package/database/index.js +26 -26
- package/database/load-database.d.ts +9 -9
- package/database/load-database.js +36 -36
- package/database/transaction.d.ts +8 -8
- package/database/transaction.js +2 -2
- package/ddl/alter-table.d.ts +26 -26
- package/ddl/alter-table.js +2 -2
- package/ddl/create-database.d.ts +3 -3
- package/ddl/create-database.js +2 -2
- package/ddl/create-index.d.ts +5 -5
- package/ddl/create-index.js +2 -2
- package/ddl/create-table.d.ts +8 -8
- package/ddl/create-table.js +2 -2
- package/ddl/create-user.d.ts +4 -4
- package/ddl/create-user.js +2 -2
- package/ddl/ddl-builder.d.ts +96 -96
- package/ddl/ddl-builder.js +565 -565
- package/ddl/ddl-repository.d.ts +135 -135
- package/ddl/ddl-repository.js +228 -228
- package/ddl/drop-database.d.ts +4 -4
- package/ddl/drop-database.js +2 -2
- package/ddl/drop-table.d.ts +4 -4
- package/ddl/drop-table.js +2 -2
- package/ddl/drop-user.d.ts +4 -4
- package/ddl/drop-user.js +2 -2
- package/ddl/foreign-key-constraint.d.ts +19 -19
- package/ddl/foreign-key-constraint.js +2 -2
- package/ddl/grant.d.ts +12 -12
- package/ddl/grant.js +2 -2
- package/ddl/index.d.ts +13 -13
- package/ddl/index.js +23 -23
- package/ddl/truncate.d.ts +3 -3
- package/ddl/truncate.js +2 -2
- package/dml/case-expression.d.ts +16 -16
- package/dml/case-expression.js +11 -11
- package/dml/delete.d.ts +8 -8
- package/dml/delete.js +2 -2
- package/dml/from.d.ts +4 -4
- package/dml/from.js +2 -2
- package/dml/group-by.d.ts +4 -4
- package/dml/group-by.js +2 -2
- package/dml/index.d.ts +11 -11
- package/dml/index.js +30 -30
- package/dml/insert.d.ts +14 -14
- package/dml/insert.js +2 -2
- package/dml/join.d.ts +7 -7
- package/dml/join.js +2 -2
- package/dml/order-by.d.ts +2 -2
- package/dml/order-by.js +2 -2
- package/dml/query-builder.d.ts +106 -106
- package/dml/query-builder.js +797 -793
- package/dml/query-builder.js.map +1 -1
- package/dml/query-repository.d.ts +84 -84
- package/dml/query-repository.js +239 -225
- package/dml/query-repository.js.map +1 -1
- package/dml/select.d.ts +29 -29
- package/dml/select.js +2 -2
- package/dml/set-options.d.ts +5 -5
- package/dml/set-options.js +2 -2
- package/dml/subquery.d.ts +5 -5
- package/dml/subquery.js +10 -10
- package/dml/update.d.ts +11 -11
- package/dml/update.js +2 -2
- package/expression/expression-token.d.ts +11 -11
- package/expression/expression-token.js +12 -12
- package/expression/expression.d.ts +6 -6
- package/expression/expression.js +2 -2
- package/expression/identifier.d.ts +7 -7
- package/expression/identifier.js +15 -15
- package/expression/index.d.ts +7 -7
- package/expression/index.js +25 -25
- package/expression/is-expression-token.d.ts +2 -2
- package/expression/is-expression-token.js +7 -7
- package/expression/key-val-expression.d.ts +7 -7
- package/expression/key-val-expression.js +2 -2
- package/expression/literal.d.ts +3 -3
- package/expression/literal.js +2 -2
- package/expression/logical.d.ts +18 -18
- package/expression/logical.js +30 -30
- package/expression/math.d.ts +17 -17
- package/expression/math.js +36 -36
- package/expression/raw.d.ts +8 -8
- package/expression/raw.js +16 -16
- package/expression/simple-expression.d.ts +8 -8
- package/expression/simple-expression.js +2 -2
- package/functions/function-aliases.d.ts +4 -4
- package/functions/function-aliases.js +12 -12
- package/functions/function-token.d.ts +29 -29
- package/functions/function-token.js +15 -15
- package/functions/functions.d.ts +19 -19
- package/functions/functions.js +94 -94
- package/functions/index.d.ts +4 -4
- package/functions/index.js +22 -22
- package/functions/is-database-function.d.ts +8 -8
- package/functions/is-database-function.js +14 -14
- package/functions/signatures/count.d.ts +14 -11
- package/functions/signatures/count.js +2 -2
- package/index.d.ts +16 -16
- package/index.js +32 -32
- package/migration/index.d.ts +3 -3
- package/migration/index.js +9 -9
- package/migration/migration-package.d.ts +14 -14
- package/migration/migration-package.js +10 -10
- package/migration/migration-record.d.ts +10 -10
- package/migration/migration-record.js +2 -2
- package/migration/migration-runner.d.ts +33 -33
- package/migration/migration-runner.js +180 -180
- package/migration/migration.d.ts +12 -12
- package/migration/migration.js +27 -27
- package/migration/migrations/001-create-migration-table.d.ts +8 -8
- package/migration/migrations/001-create-migration-table.js +54 -54
- package/migration/migrations/002-add-migration-package-column.d.ts +9 -9
- package/migration/migrations/002-add-migration-package-column.js +44 -44
- package/package.json +1 -1
- package/record/index.d.ts +1 -1
- package/record/index.js +17 -17
- package/record/record.d.ts +2 -2
- package/record/record.js +2 -2
- package/repository/index.d.ts +2 -2
- package/repository/index.js +5 -5
- package/repository/repository-options.d.ts +6 -6
- package/repository/repository-options.js +2 -2
- package/repository/repository.d.ts +29 -29
- package/repository/repository.js +68 -68
- package/schema/index.d.ts +3 -3
- package/schema/index.js +5 -5
- package/schema/schema-query-repository.d.ts +54 -54
- package/schema/schema-query-repository.js +159 -159
- package/schema/schema-table.d.ts +9 -9
- package/schema/schema-table.js +2 -2
- package/schema/schema.d.ts +4 -4
- package/schema/schema.js +2 -2
- package/seed/auto-seed.d.ts +9 -9
- package/seed/auto-seed.js +61 -61
- package/seed/create-seed-table.d.ts +8 -8
- package/seed/create-seed-table.js +64 -64
- package/seed/index.d.ts +4 -4
- package/seed/index.js +9 -9
- package/seed/seed-record.d.ts +11 -11
- package/seed/seed-record.js +2 -2
- package/seed/seed-runner.d.ts +20 -20
- package/seed/seed-runner.js +91 -91
- package/seed/seed.d.ts +12 -12
- package/seed/seed.js +27 -27
- package/tokens/index.d.ts +1 -1
- package/tokens/index.js +5 -5
- package/triggers/index.d.ts +2 -2
- package/triggers/index.js +18 -18
- package/triggers/prebuilt/index.d.ts +1 -1
- package/triggers/prebuilt/index.js +5 -5
- package/triggers/prebuilt/update-timestamp-trigger.d.ts +16 -16
- package/triggers/prebuilt/update-timestamp-trigger.js +24 -24
- package/triggers/trigger-options.d.ts +22 -22
- package/triggers/trigger-options.js +2 -2
- package/triggers/trigger.d.ts +19 -19
- package/triggers/trigger.js +23 -23
package/config/configure-db.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configureDb = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const ts_appconfig_1 = require("ts-appconfig");
|
|
6
|
-
/**
|
|
7
|
-
* Load the database's .env
|
|
8
|
-
*
|
|
9
|
-
* @param env Environment Type (must extend DatabaseEnv)
|
|
10
|
-
* @param path Path to env file
|
|
11
|
-
* @param name Database name
|
|
12
|
-
* @param options ts-appconfig options
|
|
13
|
-
* @returns Returns the loaded environment variables
|
|
14
|
-
*/
|
|
15
|
-
function configureDb(env, path, name, options = {}) {
|
|
16
|
-
return (0, ts_appconfig_1.configure)(env, Object.assign({ relativePath: (0, path_1.join)(path, name, `${name}.db.env`), fromProcessEnv: false, overwriteProcessEnv: false }, options));
|
|
17
|
-
}
|
|
18
|
-
exports.configureDb = configureDb;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureDb = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const ts_appconfig_1 = require("ts-appconfig");
|
|
6
|
+
/**
|
|
7
|
+
* Load the database's .env
|
|
8
|
+
*
|
|
9
|
+
* @param env Environment Type (must extend DatabaseEnv)
|
|
10
|
+
* @param path Path to env file
|
|
11
|
+
* @param name Database name
|
|
12
|
+
* @param options ts-appconfig options
|
|
13
|
+
* @returns Returns the loaded environment variables
|
|
14
|
+
*/
|
|
15
|
+
function configureDb(env, path, name, options = {}) {
|
|
16
|
+
return (0, ts_appconfig_1.configure)(env, Object.assign({ relativePath: (0, path_1.join)(path, name, `${name}.db.env`), fromProcessEnv: false, overwriteProcessEnv: false }, options));
|
|
17
|
+
}
|
|
18
|
+
exports.configureDb = configureDb;
|
|
19
19
|
//# sourceMappingURL=configure-db.js.map
|
package/config/database-env.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { AppConfig } from 'ts-appconfig';
|
|
2
|
-
import { DatabaseConnectionOptions } from '../database';
|
|
3
|
-
/**
|
|
4
|
-
* Loads & stores the database's configuration.
|
|
5
|
-
*
|
|
6
|
-
* The configuration file should be named `database-name.db.env` and
|
|
7
|
-
* live in the database's folder, i.e. `database/main/main.db.env`.
|
|
8
|
-
* The .env file should be .gitignore'd!
|
|
9
|
-
*/
|
|
10
|
-
export declare class DatabaseEnv extends AppConfig implements DatabaseConnectionOptions {
|
|
11
|
-
readonly host: string;
|
|
12
|
-
readonly port: number;
|
|
13
|
-
readonly username: string;
|
|
14
|
-
readonly password: string;
|
|
15
|
-
readonly database: string;
|
|
16
|
-
}
|
|
1
|
+
import { AppConfig } from 'ts-appconfig';
|
|
2
|
+
import { DatabaseConnectionOptions } from '../database';
|
|
3
|
+
/**
|
|
4
|
+
* Loads & stores the database's configuration.
|
|
5
|
+
*
|
|
6
|
+
* The configuration file should be named `database-name.db.env` and
|
|
7
|
+
* live in the database's folder, i.e. `database/main/main.db.env`.
|
|
8
|
+
* The .env file should be .gitignore'd!
|
|
9
|
+
*/
|
|
10
|
+
export declare class DatabaseEnv extends AppConfig implements DatabaseConnectionOptions {
|
|
11
|
+
readonly host: string;
|
|
12
|
+
readonly port: number;
|
|
13
|
+
readonly username: string;
|
|
14
|
+
readonly password: string;
|
|
15
|
+
readonly database: string;
|
|
16
|
+
}
|
package/config/database-env.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseEnv = void 0;
|
|
4
|
-
const ts_appconfig_1 = require("ts-appconfig");
|
|
5
|
-
/**
|
|
6
|
-
* Loads & stores the database's configuration.
|
|
7
|
-
*
|
|
8
|
-
* The configuration file should be named `database-name.db.env` and
|
|
9
|
-
* live in the database's folder, i.e. `database/main/main.db.env`.
|
|
10
|
-
* The .env file should be .gitignore'd!
|
|
11
|
-
*/
|
|
12
|
-
class DatabaseEnv extends ts_appconfig_1.AppConfig {
|
|
13
|
-
}
|
|
14
|
-
exports.DatabaseEnv = DatabaseEnv;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseEnv = void 0;
|
|
4
|
+
const ts_appconfig_1 = require("ts-appconfig");
|
|
5
|
+
/**
|
|
6
|
+
* Loads & stores the database's configuration.
|
|
7
|
+
*
|
|
8
|
+
* The configuration file should be named `database-name.db.env` and
|
|
9
|
+
* live in the database's folder, i.e. `database/main/main.db.env`.
|
|
10
|
+
* The .env file should be .gitignore'd!
|
|
11
|
+
*/
|
|
12
|
+
class DatabaseEnv extends ts_appconfig_1.AppConfig {
|
|
13
|
+
}
|
|
14
|
+
exports.DatabaseEnv = DatabaseEnv;
|
|
15
15
|
//# sourceMappingURL=database-env.js.map
|
package/config/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { configureDb } from './configure-db';
|
|
2
|
-
export { DatabaseEnv } from './database-env';
|
|
1
|
+
export { configureDb } from './configure-db';
|
|
2
|
+
export { DatabaseEnv } from './database-env';
|
package/config/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseEnv = exports.configureDb = void 0;
|
|
4
|
-
var configure_db_1 = require("./configure-db");
|
|
5
|
-
Object.defineProperty(exports, "configureDb", { enumerable: true, get: function () { return configure_db_1.configureDb; } });
|
|
6
|
-
var database_env_1 = require("./database-env");
|
|
7
|
-
Object.defineProperty(exports, "DatabaseEnv", { enumerable: true, get: function () { return database_env_1.DatabaseEnv; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseEnv = exports.configureDb = void 0;
|
|
4
|
+
var configure_db_1 = require("./configure-db");
|
|
5
|
+
Object.defineProperty(exports, "configureDb", { enumerable: true, get: function () { return configure_db_1.configureDb; } });
|
|
6
|
+
var database_env_1 = require("./database-env");
|
|
7
|
+
Object.defineProperty(exports, "DatabaseEnv", { enumerable: true, get: function () { return database_env_1.DatabaseEnv; } });
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export interface DatabaseConnectionOptions {
|
|
2
|
-
host: string;
|
|
3
|
-
port: number;
|
|
4
|
-
database: string;
|
|
5
|
-
username: string;
|
|
6
|
-
password: string;
|
|
7
|
-
}
|
|
1
|
+
export interface DatabaseConnectionOptions {
|
|
2
|
+
host: string;
|
|
3
|
+
port: number;
|
|
4
|
+
database: string;
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=connection-options.js.map
|
package/database/database.d.ts
CHANGED
|
@@ -1,204 +1,204 @@
|
|
|
1
|
-
import { DatabaseDriver } from './driver';
|
|
2
|
-
import { DatabaseEnv } from '../config';
|
|
3
|
-
import { DataDefinitionBuilder, DataDefinitionRepository } from '../ddl';
|
|
4
|
-
import { DatabaseConnectionOptions } from './connection-options';
|
|
5
|
-
import { DatabaseRecord } from '../record';
|
|
6
|
-
import { DatabaseQueryBuilder, QueryRepository, QueryRepositoryOptions } from '../dml';
|
|
7
|
-
import { SchemaQueryRepository } from '../schema/schema-query-repository';
|
|
8
|
-
import { Schema } from '../schema';
|
|
9
|
-
import { Transaction } from './transaction';
|
|
10
|
-
/**
|
|
11
|
-
* Represents a single database instance, including a driver,
|
|
12
|
-
* configuration, connection, etc.
|
|
13
|
-
*/
|
|
14
|
-
export declare abstract class Database {
|
|
15
|
-
/**
|
|
16
|
-
* Reconstructors will be used to re-initialize repositories
|
|
17
|
-
* after the database has been initialized.
|
|
18
|
-
*
|
|
19
|
-
* This allows repositories to be created in global scope
|
|
20
|
-
* before the database is init()'d
|
|
21
|
-
*/
|
|
22
|
-
protected queryRepoInitQueue: QueryRepository[];
|
|
23
|
-
protected ddlRepoInitQueue: DataDefinitionRepository[];
|
|
24
|
-
protected schemaRepoInitQueue: SchemaQueryRepository[];
|
|
25
|
-
isLoaded: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Database driver class
|
|
28
|
-
*/
|
|
29
|
-
driverType: typeof DatabaseDriver;
|
|
30
|
-
/**
|
|
31
|
-
* Database driver intance
|
|
32
|
-
*/
|
|
33
|
-
driver: DatabaseDriver;
|
|
34
|
-
/**
|
|
35
|
-
* Database configuration class
|
|
36
|
-
*/
|
|
37
|
-
envType: typeof DatabaseEnv;
|
|
38
|
-
/**
|
|
39
|
-
* Database configuration
|
|
40
|
-
*/
|
|
41
|
-
env: DatabaseEnv;
|
|
42
|
-
/**
|
|
43
|
-
* Parent path (database path)
|
|
44
|
-
*/
|
|
45
|
-
databasePath: string;
|
|
46
|
-
/**
|
|
47
|
-
* Database name (must match folder name!)
|
|
48
|
-
*/
|
|
49
|
-
name: string;
|
|
50
|
-
/**
|
|
51
|
-
* Migrations directory, relative to this database
|
|
52
|
-
* e.g. If the migrations are in `database/main/migrations`,
|
|
53
|
-
* set this to `migrations`
|
|
54
|
-
*/
|
|
55
|
-
migrations: string;
|
|
56
|
-
/**
|
|
57
|
-
* Seeds directory, relative to this database
|
|
58
|
-
* e.g. If the seeds are in `database/main/seeds`,
|
|
59
|
-
* set this to `seeds`
|
|
60
|
-
*/
|
|
61
|
-
seeds: string;
|
|
62
|
-
/**
|
|
63
|
-
* Use filesystem schema cache?
|
|
64
|
-
*/
|
|
65
|
-
useSchemaCache: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Schema storage directory, relative to this database
|
|
68
|
-
* e.g. If the schema is in `database/main/.schema`,
|
|
69
|
-
* set this to `.schema`
|
|
70
|
-
*/
|
|
71
|
-
schemaDirectory: string;
|
|
72
|
-
/**
|
|
73
|
-
* Query builder class type used to create new query builders
|
|
74
|
-
*/
|
|
75
|
-
queryBuilderType: typeof DatabaseQueryBuilder;
|
|
76
|
-
/**
|
|
77
|
-
* Query repository class type used to create new repos
|
|
78
|
-
*/
|
|
79
|
-
queryRepositoryType: typeof QueryRepository;
|
|
80
|
-
/**
|
|
81
|
-
* Query repository
|
|
82
|
-
*/
|
|
83
|
-
query: QueryRepository;
|
|
84
|
-
/**
|
|
85
|
-
* DDL builder class type used to create new builders
|
|
86
|
-
*/
|
|
87
|
-
ddlBuilderType: typeof DataDefinitionBuilder;
|
|
88
|
-
/**
|
|
89
|
-
* DDL repository class type used to create new repos
|
|
90
|
-
*/
|
|
91
|
-
ddlRepositoryType: typeof DataDefinitionRepository;
|
|
92
|
-
/**
|
|
93
|
-
* Data definition repository
|
|
94
|
-
*/
|
|
95
|
-
ddl: DataDefinitionRepository;
|
|
96
|
-
/**
|
|
97
|
-
* Schema Query repository class type used to create new repos
|
|
98
|
-
*/
|
|
99
|
-
schemaQueryRepositoryType: typeof SchemaQueryRepository;
|
|
100
|
-
/**
|
|
101
|
-
* Schema query repository
|
|
102
|
-
*/
|
|
103
|
-
schemaQuery: SchemaQueryRepository;
|
|
104
|
-
/**
|
|
105
|
-
* Database schema
|
|
106
|
-
*/
|
|
107
|
-
protected schema: Schema;
|
|
108
|
-
/**
|
|
109
|
-
* Initialize the database
|
|
110
|
-
*
|
|
111
|
-
* @param options Database options
|
|
112
|
-
*/
|
|
113
|
-
init(options?: {
|
|
114
|
-
connectionOptions?: DatabaseConnectionOptions;
|
|
115
|
-
useSchemaCache?: boolean;
|
|
116
|
-
}): Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
* Load the configuration .env
|
|
119
|
-
*/
|
|
120
|
-
configureFromEnv(): void;
|
|
121
|
-
/**
|
|
122
|
-
* Connect to the database
|
|
123
|
-
*/
|
|
124
|
-
connect(): Promise<void>;
|
|
125
|
-
/**
|
|
126
|
-
* Disconnect from the database
|
|
127
|
-
*/
|
|
128
|
-
disconnect(): Promise<void>;
|
|
129
|
-
/**
|
|
130
|
-
* Get the full relative path to this database's migrations folder
|
|
131
|
-
*
|
|
132
|
-
* @returns Returns the relative file path
|
|
133
|
-
*/
|
|
134
|
-
getMigrationsDirectory(): string;
|
|
135
|
-
/**
|
|
136
|
-
* Get the full relative path to this database's seeds folder
|
|
137
|
-
*
|
|
138
|
-
* @returns Returns the relative file path
|
|
139
|
-
*/
|
|
140
|
-
getSeedsDirectory(): string;
|
|
141
|
-
/**
|
|
142
|
-
* Get the full relative path to this database's schema folder
|
|
143
|
-
*
|
|
144
|
-
* @returns Returns the relative file path
|
|
145
|
-
*/
|
|
146
|
-
getSchemaDirectory(): string;
|
|
147
|
-
/**
|
|
148
|
-
* Get a new DDL builder
|
|
149
|
-
*
|
|
150
|
-
* @returns DDL builder
|
|
151
|
-
*/
|
|
152
|
-
getDataDefinitionBuilder(): DataDefinitionBuilder;
|
|
153
|
-
/**
|
|
154
|
-
* Get a new DDL repository
|
|
155
|
-
*
|
|
156
|
-
* @param options Repository options
|
|
157
|
-
* @returns Returns the DDL repository
|
|
158
|
-
*/
|
|
159
|
-
getDataDefinitionRepository(): DataDefinitionRepository;
|
|
160
|
-
/**
|
|
161
|
-
* Get a new query builder
|
|
162
|
-
*
|
|
163
|
-
* @returns Query builder
|
|
164
|
-
*/
|
|
165
|
-
getQueryBuilder(): DatabaseQueryBuilder;
|
|
166
|
-
/**
|
|
167
|
-
* Get a new query repository
|
|
168
|
-
*
|
|
169
|
-
* @param options Repository options
|
|
170
|
-
* @returns Returns the query repository
|
|
171
|
-
*/
|
|
172
|
-
getQueryRepository<T extends DatabaseRecord = DatabaseRecord>(options?: Omit<QueryRepositoryOptions, 'driver' | 'queryBuilderType' | 'functions'>): QueryRepository<T>;
|
|
173
|
-
/**
|
|
174
|
-
* Get a new schema query repository
|
|
175
|
-
*
|
|
176
|
-
* @returns Schema Query Repository
|
|
177
|
-
*/
|
|
178
|
-
getSchemaQueryRepository(): SchemaQueryRepository;
|
|
179
|
-
/**
|
|
180
|
-
* Build & save the database schema
|
|
181
|
-
*/
|
|
182
|
-
buildSchema(): Promise<void>;
|
|
183
|
-
/**
|
|
184
|
-
* Save the database schema
|
|
185
|
-
*/
|
|
186
|
-
saveSchema(): Promise<void>;
|
|
187
|
-
/**
|
|
188
|
-
* Load the database schema
|
|
189
|
-
*/
|
|
190
|
-
loadSchema(): Promise<void>;
|
|
191
|
-
/**
|
|
192
|
-
* Get schema metadata
|
|
193
|
-
*
|
|
194
|
-
* @returns Schema
|
|
195
|
-
*/
|
|
196
|
-
getSchema(): Promise<Schema>;
|
|
197
|
-
/**
|
|
198
|
-
* Run a transaction
|
|
199
|
-
*
|
|
200
|
-
* @param fn Transaction callback
|
|
201
|
-
* @returns Passes the return from the transaction callback
|
|
202
|
-
*/
|
|
203
|
-
transaction<T>(fn: (transaction: Transaction) => Promise<T>): Promise<T>;
|
|
204
|
-
}
|
|
1
|
+
import { DatabaseDriver } from './driver';
|
|
2
|
+
import { DatabaseEnv } from '../config';
|
|
3
|
+
import { DataDefinitionBuilder, DataDefinitionRepository } from '../ddl';
|
|
4
|
+
import { DatabaseConnectionOptions } from './connection-options';
|
|
5
|
+
import { DatabaseRecord } from '../record';
|
|
6
|
+
import { DatabaseQueryBuilder, QueryRepository, QueryRepositoryOptions } from '../dml';
|
|
7
|
+
import { SchemaQueryRepository } from '../schema/schema-query-repository';
|
|
8
|
+
import { Schema } from '../schema';
|
|
9
|
+
import { Transaction } from './transaction';
|
|
10
|
+
/**
|
|
11
|
+
* Represents a single database instance, including a driver,
|
|
12
|
+
* configuration, connection, etc.
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class Database {
|
|
15
|
+
/**
|
|
16
|
+
* Reconstructors will be used to re-initialize repositories
|
|
17
|
+
* after the database has been initialized.
|
|
18
|
+
*
|
|
19
|
+
* This allows repositories to be created in global scope
|
|
20
|
+
* before the database is init()'d
|
|
21
|
+
*/
|
|
22
|
+
protected queryRepoInitQueue: QueryRepository[];
|
|
23
|
+
protected ddlRepoInitQueue: DataDefinitionRepository[];
|
|
24
|
+
protected schemaRepoInitQueue: SchemaQueryRepository[];
|
|
25
|
+
isLoaded: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Database driver class
|
|
28
|
+
*/
|
|
29
|
+
driverType: typeof DatabaseDriver;
|
|
30
|
+
/**
|
|
31
|
+
* Database driver intance
|
|
32
|
+
*/
|
|
33
|
+
driver: DatabaseDriver;
|
|
34
|
+
/**
|
|
35
|
+
* Database configuration class
|
|
36
|
+
*/
|
|
37
|
+
envType: typeof DatabaseEnv;
|
|
38
|
+
/**
|
|
39
|
+
* Database configuration
|
|
40
|
+
*/
|
|
41
|
+
env: DatabaseEnv;
|
|
42
|
+
/**
|
|
43
|
+
* Parent path (database path)
|
|
44
|
+
*/
|
|
45
|
+
databasePath: string;
|
|
46
|
+
/**
|
|
47
|
+
* Database name (must match folder name!)
|
|
48
|
+
*/
|
|
49
|
+
name: string;
|
|
50
|
+
/**
|
|
51
|
+
* Migrations directory, relative to this database
|
|
52
|
+
* e.g. If the migrations are in `database/main/migrations`,
|
|
53
|
+
* set this to `migrations`
|
|
54
|
+
*/
|
|
55
|
+
migrations: string;
|
|
56
|
+
/**
|
|
57
|
+
* Seeds directory, relative to this database
|
|
58
|
+
* e.g. If the seeds are in `database/main/seeds`,
|
|
59
|
+
* set this to `seeds`
|
|
60
|
+
*/
|
|
61
|
+
seeds: string;
|
|
62
|
+
/**
|
|
63
|
+
* Use filesystem schema cache?
|
|
64
|
+
*/
|
|
65
|
+
useSchemaCache: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Schema storage directory, relative to this database
|
|
68
|
+
* e.g. If the schema is in `database/main/.schema`,
|
|
69
|
+
* set this to `.schema`
|
|
70
|
+
*/
|
|
71
|
+
schemaDirectory: string;
|
|
72
|
+
/**
|
|
73
|
+
* Query builder class type used to create new query builders
|
|
74
|
+
*/
|
|
75
|
+
queryBuilderType: typeof DatabaseQueryBuilder;
|
|
76
|
+
/**
|
|
77
|
+
* Query repository class type used to create new repos
|
|
78
|
+
*/
|
|
79
|
+
queryRepositoryType: typeof QueryRepository;
|
|
80
|
+
/**
|
|
81
|
+
* Query repository
|
|
82
|
+
*/
|
|
83
|
+
query: QueryRepository;
|
|
84
|
+
/**
|
|
85
|
+
* DDL builder class type used to create new builders
|
|
86
|
+
*/
|
|
87
|
+
ddlBuilderType: typeof DataDefinitionBuilder;
|
|
88
|
+
/**
|
|
89
|
+
* DDL repository class type used to create new repos
|
|
90
|
+
*/
|
|
91
|
+
ddlRepositoryType: typeof DataDefinitionRepository;
|
|
92
|
+
/**
|
|
93
|
+
* Data definition repository
|
|
94
|
+
*/
|
|
95
|
+
ddl: DataDefinitionRepository;
|
|
96
|
+
/**
|
|
97
|
+
* Schema Query repository class type used to create new repos
|
|
98
|
+
*/
|
|
99
|
+
schemaQueryRepositoryType: typeof SchemaQueryRepository;
|
|
100
|
+
/**
|
|
101
|
+
* Schema query repository
|
|
102
|
+
*/
|
|
103
|
+
schemaQuery: SchemaQueryRepository;
|
|
104
|
+
/**
|
|
105
|
+
* Database schema
|
|
106
|
+
*/
|
|
107
|
+
protected schema: Schema;
|
|
108
|
+
/**
|
|
109
|
+
* Initialize the database
|
|
110
|
+
*
|
|
111
|
+
* @param options Database options
|
|
112
|
+
*/
|
|
113
|
+
init(options?: {
|
|
114
|
+
connectionOptions?: DatabaseConnectionOptions;
|
|
115
|
+
useSchemaCache?: boolean;
|
|
116
|
+
}): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Load the configuration .env
|
|
119
|
+
*/
|
|
120
|
+
configureFromEnv(): void;
|
|
121
|
+
/**
|
|
122
|
+
* Connect to the database
|
|
123
|
+
*/
|
|
124
|
+
connect(): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Disconnect from the database
|
|
127
|
+
*/
|
|
128
|
+
disconnect(): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Get the full relative path to this database's migrations folder
|
|
131
|
+
*
|
|
132
|
+
* @returns Returns the relative file path
|
|
133
|
+
*/
|
|
134
|
+
getMigrationsDirectory(): string;
|
|
135
|
+
/**
|
|
136
|
+
* Get the full relative path to this database's seeds folder
|
|
137
|
+
*
|
|
138
|
+
* @returns Returns the relative file path
|
|
139
|
+
*/
|
|
140
|
+
getSeedsDirectory(): string;
|
|
141
|
+
/**
|
|
142
|
+
* Get the full relative path to this database's schema folder
|
|
143
|
+
*
|
|
144
|
+
* @returns Returns the relative file path
|
|
145
|
+
*/
|
|
146
|
+
getSchemaDirectory(): string;
|
|
147
|
+
/**
|
|
148
|
+
* Get a new DDL builder
|
|
149
|
+
*
|
|
150
|
+
* @returns DDL builder
|
|
151
|
+
*/
|
|
152
|
+
getDataDefinitionBuilder(): DataDefinitionBuilder;
|
|
153
|
+
/**
|
|
154
|
+
* Get a new DDL repository
|
|
155
|
+
*
|
|
156
|
+
* @param options Repository options
|
|
157
|
+
* @returns Returns the DDL repository
|
|
158
|
+
*/
|
|
159
|
+
getDataDefinitionRepository(): DataDefinitionRepository;
|
|
160
|
+
/**
|
|
161
|
+
* Get a new query builder
|
|
162
|
+
*
|
|
163
|
+
* @returns Query builder
|
|
164
|
+
*/
|
|
165
|
+
getQueryBuilder(): DatabaseQueryBuilder;
|
|
166
|
+
/**
|
|
167
|
+
* Get a new query repository
|
|
168
|
+
*
|
|
169
|
+
* @param options Repository options
|
|
170
|
+
* @returns Returns the query repository
|
|
171
|
+
*/
|
|
172
|
+
getQueryRepository<T extends DatabaseRecord = DatabaseRecord>(options?: Omit<QueryRepositoryOptions, 'driver' | 'queryBuilderType' | 'functions'>): QueryRepository<T>;
|
|
173
|
+
/**
|
|
174
|
+
* Get a new schema query repository
|
|
175
|
+
*
|
|
176
|
+
* @returns Schema Query Repository
|
|
177
|
+
*/
|
|
178
|
+
getSchemaQueryRepository(): SchemaQueryRepository;
|
|
179
|
+
/**
|
|
180
|
+
* Build & save the database schema
|
|
181
|
+
*/
|
|
182
|
+
buildSchema(): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Save the database schema
|
|
185
|
+
*/
|
|
186
|
+
saveSchema(): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Load the database schema
|
|
189
|
+
*/
|
|
190
|
+
loadSchema(): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* Get schema metadata
|
|
193
|
+
*
|
|
194
|
+
* @returns Schema
|
|
195
|
+
*/
|
|
196
|
+
getSchema(): Promise<Schema>;
|
|
197
|
+
/**
|
|
198
|
+
* Run a transaction
|
|
199
|
+
*
|
|
200
|
+
* @param fn Transaction callback
|
|
201
|
+
* @returns Passes the return from the transaction callback
|
|
202
|
+
*/
|
|
203
|
+
transaction<T>(fn: (transaction: Transaction) => Promise<T>): Promise<T>;
|
|
204
|
+
}
|