@riao/dbal 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +54 -53
- package/builder/sql-builder.js +161 -157
- package/builder/sql-builder.js.map +1 -1
- 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/create-column-template.d.ts +11 -0
- package/column/create-column-template.js +57 -0
- package/column/create-column-template.js.map +1 -0
- package/column/index.d.ts +4 -3
- package/column/index.js +20 -19
- package/column/index.js.map +1 -1
- 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 +125 -106
- package/dml/query-builder.js +991 -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 +44 -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 +28 -18
- package/expression/logical.js +54 -30
- package/expression/logical.js.map +1 -1
- 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 +6 -4
- package/functions/function-aliases.js +16 -12
- package/functions/function-aliases.js.map +1 -1
- package/functions/function-token.d.ts +33 -29
- package/functions/function-token.js +19 -15
- package/functions/function-token.js.map +1 -1
- package/functions/functions.d.ts +23 -19
- package/functions/functions.js +126 -94
- package/functions/functions.js.map +1 -1
- 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/ddl/ddl-repository.js
CHANGED
|
@@ -1,229 +1,229 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DataDefinitionRepository = void 0;
|
|
13
|
-
const ddl_1 = require("../ddl");
|
|
14
|
-
const repository_1 = require("../repository");
|
|
15
|
-
/**
|
|
16
|
-
* Use the DDL Repository to create & modify your database schema
|
|
17
|
-
*/
|
|
18
|
-
class DataDefinitionRepository extends repository_1.Repository {
|
|
19
|
-
constructor(options) {
|
|
20
|
-
var _a;
|
|
21
|
-
super(options);
|
|
22
|
-
this.ddlBuilderType = ddl_1.DataDefinitionBuilder;
|
|
23
|
-
this.ddlBuilderType = (_a = options.ddlBuilderType) !== null && _a !== void 0 ? _a : this.ddlBuilderType;
|
|
24
|
-
}
|
|
25
|
-
init(options) {
|
|
26
|
-
super.init(options);
|
|
27
|
-
this.isReady = true;
|
|
28
|
-
}
|
|
29
|
-
getDDLBuilder() {
|
|
30
|
-
return new this.ddlBuilderType();
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Temporarily disable foreign key checks on the session.
|
|
34
|
-
* Some databases may require escalated priveleges
|
|
35
|
-
*/
|
|
36
|
-
disableForeignKeyChecks() {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
yield this.query(this.getDDLBuilder().disableForeignKeyChecks());
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Re-enable foreign key checks on the session.
|
|
43
|
-
* Some databases may require escalated priveleges
|
|
44
|
-
*/
|
|
45
|
-
enableForeignKeyChecks() {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
yield this.query(this.getDDLBuilder().enableForeignKeyChecks());
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Create a new database
|
|
52
|
-
*
|
|
53
|
-
* @param options Database options
|
|
54
|
-
*/
|
|
55
|
-
createDatabase(options) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
yield this.query(this.getDDLBuilder().createDatabase(options));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Create a new table
|
|
62
|
-
*
|
|
63
|
-
* @param options Table options
|
|
64
|
-
*/
|
|
65
|
-
createTable(options) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
yield this.query(this.getDDLBuilder().createTable(options));
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Create an index on a table
|
|
72
|
-
*
|
|
73
|
-
* @param options Index options
|
|
74
|
-
*/
|
|
75
|
-
createIndex(options) {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
yield this.query(this.getDDLBuilder().createIndex(options));
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Create a new user
|
|
82
|
-
*
|
|
83
|
-
* @param options Table options
|
|
84
|
-
*/
|
|
85
|
-
createUser(options) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
yield this.query(this.getDDLBuilder().createUser(options));
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* IMPORTANT: UNSTABLE. Grant is currently only compatible with
|
|
92
|
-
* mysql and mssql and may cause unintended side-effects and/or
|
|
93
|
-
* privilege escalation.
|
|
94
|
-
* This should not be used in most circumstances!
|
|
95
|
-
* Use a dedicated database connection for this method, as it may change
|
|
96
|
-
* the database connection's default database.
|
|
97
|
-
* This method and it's arguments are likely to change in future versions
|
|
98
|
-
*
|
|
99
|
-
* @param options Grant options
|
|
100
|
-
* @returns
|
|
101
|
-
*/
|
|
102
|
-
grant(options) {
|
|
103
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
yield this.query(this.getDDLBuilder().grant(options));
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Add columns to a table
|
|
109
|
-
*
|
|
110
|
-
* @param options Add column options
|
|
111
|
-
*/
|
|
112
|
-
addColumns(options) {
|
|
113
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
yield this.query(this.getDDLBuilder().addColumns(options));
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Add a foreign key to a table
|
|
119
|
-
*
|
|
120
|
-
* @param options Foreign key options
|
|
121
|
-
*/
|
|
122
|
-
addForeignKey(options) {
|
|
123
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
yield this.query(this.getDDLBuilder().addForeignKey(options));
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Change a column
|
|
129
|
-
*
|
|
130
|
-
* @param options Column options
|
|
131
|
-
*/
|
|
132
|
-
changeColumn(options) {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
yield this.query(this.getDDLBuilder().changeColumn(options));
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Drop a column
|
|
139
|
-
*
|
|
140
|
-
* @param options Drop options
|
|
141
|
-
*/
|
|
142
|
-
dropColumn(options) {
|
|
143
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
-
yield this.query(this.getDDLBuilder().dropColumn(options));
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Drop a foreign key constraint
|
|
149
|
-
*
|
|
150
|
-
* @param options Drop options
|
|
151
|
-
*/
|
|
152
|
-
dropForeignKey(options) {
|
|
153
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
yield this.query(this.getDDLBuilder().dropForeignKey(options));
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Rename a table
|
|
159
|
-
*
|
|
160
|
-
* @param options Rename options
|
|
161
|
-
*/
|
|
162
|
-
renameTable(options) {
|
|
163
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
-
yield this.query(this.getDDLBuilder().renameTable(options));
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Drop a database
|
|
169
|
-
*
|
|
170
|
-
* @param options Options
|
|
171
|
-
*/
|
|
172
|
-
dropDatabase(options) {
|
|
173
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
yield this.query(this.getDDLBuilder().dropDatabase(options));
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Drop an existing table
|
|
179
|
-
*
|
|
180
|
-
* @param options Options
|
|
181
|
-
*/
|
|
182
|
-
dropTable(options) {
|
|
183
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
-
yield this.query(this.getDDLBuilder().dropTable(options));
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Drop user(s)
|
|
189
|
-
*
|
|
190
|
-
* @param options Options
|
|
191
|
-
*/
|
|
192
|
-
dropUser(options) {
|
|
193
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
-
yield this.query(this.getDDLBuilder().dropUser(options));
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Truncate an existing table
|
|
199
|
-
*
|
|
200
|
-
* @param options Options
|
|
201
|
-
*/
|
|
202
|
-
truncate(options) {
|
|
203
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
-
yield this.query(this.getDDLBuilder().truncate(options));
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Create a new trigger
|
|
209
|
-
*
|
|
210
|
-
* @param options Trigger options
|
|
211
|
-
*/
|
|
212
|
-
createTrigger(options) {
|
|
213
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
yield this.query(this.getDDLBuilder().createTrigger(options));
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Drop an existing trigger
|
|
219
|
-
*
|
|
220
|
-
* @param options Trigger options
|
|
221
|
-
*/
|
|
222
|
-
dropTrigger(options) {
|
|
223
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
-
yield this.query(this.getDDLBuilder().dropTrigger(options));
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
exports.DataDefinitionRepository = DataDefinitionRepository;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DataDefinitionRepository = void 0;
|
|
13
|
+
const ddl_1 = require("../ddl");
|
|
14
|
+
const repository_1 = require("../repository");
|
|
15
|
+
/**
|
|
16
|
+
* Use the DDL Repository to create & modify your database schema
|
|
17
|
+
*/
|
|
18
|
+
class DataDefinitionRepository extends repository_1.Repository {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
var _a;
|
|
21
|
+
super(options);
|
|
22
|
+
this.ddlBuilderType = ddl_1.DataDefinitionBuilder;
|
|
23
|
+
this.ddlBuilderType = (_a = options.ddlBuilderType) !== null && _a !== void 0 ? _a : this.ddlBuilderType;
|
|
24
|
+
}
|
|
25
|
+
init(options) {
|
|
26
|
+
super.init(options);
|
|
27
|
+
this.isReady = true;
|
|
28
|
+
}
|
|
29
|
+
getDDLBuilder() {
|
|
30
|
+
return new this.ddlBuilderType();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Temporarily disable foreign key checks on the session.
|
|
34
|
+
* Some databases may require escalated priveleges
|
|
35
|
+
*/
|
|
36
|
+
disableForeignKeyChecks() {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
yield this.query(this.getDDLBuilder().disableForeignKeyChecks());
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Re-enable foreign key checks on the session.
|
|
43
|
+
* Some databases may require escalated priveleges
|
|
44
|
+
*/
|
|
45
|
+
enableForeignKeyChecks() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
yield this.query(this.getDDLBuilder().enableForeignKeyChecks());
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a new database
|
|
52
|
+
*
|
|
53
|
+
* @param options Database options
|
|
54
|
+
*/
|
|
55
|
+
createDatabase(options) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
yield this.query(this.getDDLBuilder().createDatabase(options));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a new table
|
|
62
|
+
*
|
|
63
|
+
* @param options Table options
|
|
64
|
+
*/
|
|
65
|
+
createTable(options) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
yield this.query(this.getDDLBuilder().createTable(options));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create an index on a table
|
|
72
|
+
*
|
|
73
|
+
* @param options Index options
|
|
74
|
+
*/
|
|
75
|
+
createIndex(options) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
yield this.query(this.getDDLBuilder().createIndex(options));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create a new user
|
|
82
|
+
*
|
|
83
|
+
* @param options Table options
|
|
84
|
+
*/
|
|
85
|
+
createUser(options) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
yield this.query(this.getDDLBuilder().createUser(options));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* IMPORTANT: UNSTABLE. Grant is currently only compatible with
|
|
92
|
+
* mysql and mssql and may cause unintended side-effects and/or
|
|
93
|
+
* privilege escalation.
|
|
94
|
+
* This should not be used in most circumstances!
|
|
95
|
+
* Use a dedicated database connection for this method, as it may change
|
|
96
|
+
* the database connection's default database.
|
|
97
|
+
* This method and it's arguments are likely to change in future versions
|
|
98
|
+
*
|
|
99
|
+
* @param options Grant options
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
grant(options) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
yield this.query(this.getDDLBuilder().grant(options));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Add columns to a table
|
|
109
|
+
*
|
|
110
|
+
* @param options Add column options
|
|
111
|
+
*/
|
|
112
|
+
addColumns(options) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
yield this.query(this.getDDLBuilder().addColumns(options));
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Add a foreign key to a table
|
|
119
|
+
*
|
|
120
|
+
* @param options Foreign key options
|
|
121
|
+
*/
|
|
122
|
+
addForeignKey(options) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
yield this.query(this.getDDLBuilder().addForeignKey(options));
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Change a column
|
|
129
|
+
*
|
|
130
|
+
* @param options Column options
|
|
131
|
+
*/
|
|
132
|
+
changeColumn(options) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
yield this.query(this.getDDLBuilder().changeColumn(options));
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Drop a column
|
|
139
|
+
*
|
|
140
|
+
* @param options Drop options
|
|
141
|
+
*/
|
|
142
|
+
dropColumn(options) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
yield this.query(this.getDDLBuilder().dropColumn(options));
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Drop a foreign key constraint
|
|
149
|
+
*
|
|
150
|
+
* @param options Drop options
|
|
151
|
+
*/
|
|
152
|
+
dropForeignKey(options) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
yield this.query(this.getDDLBuilder().dropForeignKey(options));
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Rename a table
|
|
159
|
+
*
|
|
160
|
+
* @param options Rename options
|
|
161
|
+
*/
|
|
162
|
+
renameTable(options) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
yield this.query(this.getDDLBuilder().renameTable(options));
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Drop a database
|
|
169
|
+
*
|
|
170
|
+
* @param options Options
|
|
171
|
+
*/
|
|
172
|
+
dropDatabase(options) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
yield this.query(this.getDDLBuilder().dropDatabase(options));
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Drop an existing table
|
|
179
|
+
*
|
|
180
|
+
* @param options Options
|
|
181
|
+
*/
|
|
182
|
+
dropTable(options) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
yield this.query(this.getDDLBuilder().dropTable(options));
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Drop user(s)
|
|
189
|
+
*
|
|
190
|
+
* @param options Options
|
|
191
|
+
*/
|
|
192
|
+
dropUser(options) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
yield this.query(this.getDDLBuilder().dropUser(options));
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Truncate an existing table
|
|
199
|
+
*
|
|
200
|
+
* @param options Options
|
|
201
|
+
*/
|
|
202
|
+
truncate(options) {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
yield this.query(this.getDDLBuilder().truncate(options));
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Create a new trigger
|
|
209
|
+
*
|
|
210
|
+
* @param options Trigger options
|
|
211
|
+
*/
|
|
212
|
+
createTrigger(options) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
yield this.query(this.getDDLBuilder().createTrigger(options));
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Drop an existing trigger
|
|
219
|
+
*
|
|
220
|
+
* @param options Trigger options
|
|
221
|
+
*/
|
|
222
|
+
dropTrigger(options) {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
+
yield this.query(this.getDDLBuilder().dropTrigger(options));
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
exports.DataDefinitionRepository = DataDefinitionRepository;
|
|
229
229
|
//# sourceMappingURL=ddl-repository.js.map
|
package/ddl/drop-database.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface DropDatabaseOptions {
|
|
2
|
-
name: string;
|
|
3
|
-
ifExists?: boolean;
|
|
4
|
-
}
|
|
1
|
+
export interface DropDatabaseOptions {
|
|
2
|
+
name: string;
|
|
3
|
+
ifExists?: boolean;
|
|
4
|
+
}
|
package/ddl/drop-database.js
CHANGED
|
@@ -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=drop-database.js.map
|
package/ddl/drop-table.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface DropTableOptions {
|
|
2
|
-
tables: string | string[];
|
|
3
|
-
ifExists?: boolean;
|
|
4
|
-
}
|
|
1
|
+
export interface DropTableOptions {
|
|
2
|
+
tables: string | string[];
|
|
3
|
+
ifExists?: boolean;
|
|
4
|
+
}
|
package/ddl/drop-table.js
CHANGED
|
@@ -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=drop-table.js.map
|
package/ddl/drop-user.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface DropUserOptions {
|
|
2
|
-
names: string | string[];
|
|
3
|
-
ifExists?: boolean;
|
|
4
|
-
}
|
|
1
|
+
export interface DropUserOptions {
|
|
2
|
+
names: string | string[];
|
|
3
|
+
ifExists?: boolean;
|
|
4
|
+
}
|
package/ddl/drop-user.js
CHANGED
|
@@ -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=drop-user.js.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export type ForeignKeyReferenceOption = 'RESTRICT' | 'CASCADE' | 'SET NULL';
|
|
2
|
-
export interface FKReferenceSingle {
|
|
3
|
-
column: string;
|
|
4
|
-
referencesTable: string;
|
|
5
|
-
referencesColumn: string;
|
|
6
|
-
}
|
|
7
|
-
export interface FKReferenceMultiple {
|
|
8
|
-
columns: string[];
|
|
9
|
-
referencesTable: string;
|
|
10
|
-
referencesColumns: string[];
|
|
11
|
-
}
|
|
12
|
-
export type FKReference = FKReferenceSingle | FKReferenceMultiple;
|
|
13
|
-
export interface FKOptions {
|
|
14
|
-
name?: string;
|
|
15
|
-
onUpdate?: ForeignKeyReferenceOption;
|
|
16
|
-
onDelete?: ForeignKeyReferenceOption;
|
|
17
|
-
}
|
|
18
|
-
export type ForeignKeyConstraint = FKOptions & FKReference;
|
|
19
|
-
export type InlineForeignKeyConstraint = FKOptions & Omit<FKReferenceSingle, 'column'>;
|
|
1
|
+
export type ForeignKeyReferenceOption = 'RESTRICT' | 'CASCADE' | 'SET NULL';
|
|
2
|
+
export interface FKReferenceSingle {
|
|
3
|
+
column: string;
|
|
4
|
+
referencesTable: string;
|
|
5
|
+
referencesColumn: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FKReferenceMultiple {
|
|
8
|
+
columns: string[];
|
|
9
|
+
referencesTable: string;
|
|
10
|
+
referencesColumns: string[];
|
|
11
|
+
}
|
|
12
|
+
export type FKReference = FKReferenceSingle | FKReferenceMultiple;
|
|
13
|
+
export interface FKOptions {
|
|
14
|
+
name?: string;
|
|
15
|
+
onUpdate?: ForeignKeyReferenceOption;
|
|
16
|
+
onDelete?: ForeignKeyReferenceOption;
|
|
17
|
+
}
|
|
18
|
+
export type ForeignKeyConstraint = FKOptions & FKReference;
|
|
19
|
+
export type InlineForeignKeyConstraint = FKOptions & Omit<FKReferenceSingle, 'column'>;
|
|
@@ -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=foreign-key-constraint.js.map
|
package/ddl/grant.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export type GrantPrivileges = 'ALL' | 'INSERT' | 'SELECT' | 'UPDATE' | 'DELETE';
|
|
2
|
-
export type GrantOn = '*' | {
|
|
3
|
-
database: string;
|
|
4
|
-
} | {
|
|
5
|
-
database: string;
|
|
6
|
-
table: string;
|
|
7
|
-
};
|
|
8
|
-
export interface GrantOptions {
|
|
9
|
-
privileges: GrantPrivileges | GrantPrivileges[];
|
|
10
|
-
on: GrantOn;
|
|
11
|
-
to: string | string[];
|
|
12
|
-
}
|
|
1
|
+
export type GrantPrivileges = 'ALL' | 'INSERT' | 'SELECT' | 'UPDATE' | 'DELETE';
|
|
2
|
+
export type GrantOn = '*' | {
|
|
3
|
+
database: string;
|
|
4
|
+
} | {
|
|
5
|
+
database: string;
|
|
6
|
+
table: string;
|
|
7
|
+
};
|
|
8
|
+
export interface GrantOptions {
|
|
9
|
+
privileges: GrantPrivileges | GrantPrivileges[];
|
|
10
|
+
on: GrantOn;
|
|
11
|
+
to: string | string[];
|
|
12
|
+
}
|
package/ddl/grant.js
CHANGED
|
@@ -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=grant.js.map
|
package/ddl/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from './alter-table';
|
|
2
|
-
export { DataDefinitionBuilder } from './ddl-builder';
|
|
3
|
-
export { DataDefinitionRepository, DDLRepositoryOptions, } from './ddl-repository';
|
|
4
|
-
export { CreateDatabaseOptions } from './create-database';
|
|
5
|
-
export { CreateIndexOptions } from './create-index';
|
|
6
|
-
export { CreateTableOptions } from './create-table';
|
|
7
|
-
export { CreateUserOptions } from './create-user';
|
|
8
|
-
export * from './grant';
|
|
9
|
-
export { DropDatabaseOptions } from './drop-database';
|
|
10
|
-
export { DropTableOptions } from './drop-table';
|
|
11
|
-
export { DropUserOptions } from './drop-user';
|
|
12
|
-
export { ForeignKeyReferenceOption, ForeignKeyConstraint, } from './foreign-key-constraint';
|
|
13
|
-
export { TruncateOptions } from './truncate';
|
|
1
|
+
export * from './alter-table';
|
|
2
|
+
export { DataDefinitionBuilder } from './ddl-builder';
|
|
3
|
+
export { DataDefinitionRepository, DDLRepositoryOptions, } from './ddl-repository';
|
|
4
|
+
export { CreateDatabaseOptions } from './create-database';
|
|
5
|
+
export { CreateIndexOptions } from './create-index';
|
|
6
|
+
export { CreateTableOptions } from './create-table';
|
|
7
|
+
export { CreateUserOptions } from './create-user';
|
|
8
|
+
export * from './grant';
|
|
9
|
+
export { DropDatabaseOptions } from './drop-database';
|
|
10
|
+
export { DropTableOptions } from './drop-table';
|
|
11
|
+
export { DropUserOptions } from './drop-user';
|
|
12
|
+
export { ForeignKeyReferenceOption, ForeignKeyConstraint, } from './foreign-key-constraint';
|
|
13
|
+
export { TruncateOptions } from './truncate';
|
package/ddl/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.DataDefinitionRepository = exports.DataDefinitionBuilder = void 0;
|
|
18
|
-
__exportStar(require("./alter-table"), exports);
|
|
19
|
-
var ddl_builder_1 = require("./ddl-builder");
|
|
20
|
-
Object.defineProperty(exports, "DataDefinitionBuilder", { enumerable: true, get: function () { return ddl_builder_1.DataDefinitionBuilder; } });
|
|
21
|
-
var ddl_repository_1 = require("./ddl-repository");
|
|
22
|
-
Object.defineProperty(exports, "DataDefinitionRepository", { enumerable: true, get: function () { return ddl_repository_1.DataDefinitionRepository; } });
|
|
23
|
-
__exportStar(require("./grant"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DataDefinitionRepository = exports.DataDefinitionBuilder = void 0;
|
|
18
|
+
__exportStar(require("./alter-table"), exports);
|
|
19
|
+
var ddl_builder_1 = require("./ddl-builder");
|
|
20
|
+
Object.defineProperty(exports, "DataDefinitionBuilder", { enumerable: true, get: function () { return ddl_builder_1.DataDefinitionBuilder; } });
|
|
21
|
+
var ddl_repository_1 = require("./ddl-repository");
|
|
22
|
+
Object.defineProperty(exports, "DataDefinitionRepository", { enumerable: true, get: function () { return ddl_repository_1.DataDefinitionRepository; } });
|
|
23
|
+
__exportStar(require("./grant"), exports);
|
|
24
24
|
//# sourceMappingURL=index.js.map
|