remult 0.25.8 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +194 -129
- package/esm/graphql.js +131 -59
- package/esm/index.js +1 -1
- package/esm/migrations/compare-migration-snapshots.js +61 -0
- package/esm/migrations/generate-migrations.js +68 -0
- package/esm/migrations/index.js +2 -0
- package/esm/migrations/migrate.js +90 -0
- package/esm/migrations/migration-types.js +36 -0
- package/esm/migrations/update-migrations-ts-file.js +115 -0
- package/esm/postgres/postgres-data-provider.js +24 -3
- package/esm/postgres/schema-builder.js +35 -26
- package/esm/remult-better-sqlite3.js +47 -0
- package/esm/remult-bun-sqlite.js +41 -0
- package/esm/remult-knex/index.js +180 -51
- package/esm/remult-mongo.js +2 -2
- package/esm/remult-sql-js.js +3 -78
- package/esm/remult-sqlite-core.js +104 -0
- package/esm/server/expressBridge.js +130 -29
- package/esm/server/initAsyncHooks.js +75 -1
- package/esm/src/CompoundIdField.js +8 -2
- package/esm/src/context.js +20 -24
- package/esm/src/data-api.js +71 -30
- package/esm/src/data-providers/rest-data-provider.js +17 -15
- package/esm/src/data-providers/sql-database.js +32 -7
- package/esm/src/data-providers/web-sql-data-provider.js +1 -9
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +37 -11
- package/esm/src/filter/filter-interfaces.js +229 -17
- package/esm/src/isOfType.js +9 -0
- package/esm/src/remult3/Fields.js +70 -18
- package/esm/src/remult3/RepositoryImplementation.js +47 -21
- package/esm/src/remult3/addValidator.js +15 -0
- package/esm/src/remult3/remult3.js +28 -57
- package/esm/src/server-action.js +4 -4
- package/esm/src/validators.js +6 -3
- package/esm/src/valueConverters.js +1 -1
- package/graphql.js +156 -71
- package/index.d.ts +4 -4
- package/index.js +2 -1
- package/migrations/compare-migration-snapshots.d.ts +27 -0
- package/migrations/compare-migration-snapshots.js +165 -0
- package/migrations/generate-migrations.d.ts +21 -0
- package/migrations/generate-migrations.js +104 -0
- package/migrations/index.d.ts +3 -0
- package/migrations/index.js +7 -0
- package/migrations/migrate.d.ts +27 -0
- package/migrations/migrate.js +175 -0
- package/migrations/migration-types.d.ts +48 -0
- package/migrations/migration-types.js +88 -0
- package/migrations/update-migrations-ts-file.d.ts +1 -0
- package/migrations/update-migrations-ts-file.js +141 -0
- package/package.json +21 -1
- package/postgres/postgres-data-provider.d.ts +8 -3
- package/postgres/postgres-data-provider.js +46 -3
- package/postgres/schema-builder.js +81 -48
- package/remult-better-sqlite3.d.ts +12 -0
- package/remult-better-sqlite3.js +64 -0
- package/remult-bun-sqlite.d.ts +11 -0
- package/remult-bun-sqlite.js +56 -0
- package/remult-knex/index.d.ts +12 -5
- package/remult-knex/index.js +257 -90
- package/remult-mongo.d.ts +2 -2
- package/remult-mongo.js +2 -2
- package/remult-sql-js.d.ts +2 -15
- package/remult-sql-js.js +11 -152
- package/remult-sqlite-core.d.ts +21 -0
- package/remult-sqlite-core.js +217 -0
- package/server/expressBridge.d.ts +30 -1
- package/server/expressBridge.js +140 -32
- package/server/initAsyncHooks.d.ts +16 -0
- package/server/initAsyncHooks.js +128 -2
- package/src/CompoundIdField.js +8 -2
- package/src/column-interfaces.d.ts +9 -3
- package/src/context.d.ts +8 -6
- package/src/context.js +27 -36
- package/src/data-api.d.ts +13 -9
- package/src/data-api.js +184 -135
- package/src/data-providers/rest-data-provider.js +26 -15
- package/src/data-providers/sql-database.d.ts +17 -5
- package/src/data-providers/sql-database.js +31 -7
- package/src/data-providers/web-sql-data-provider.d.ts +1 -2
- package/src/data-providers/web-sql-data-provider.js +4 -8
- package/src/entity.d.ts +64 -6
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +31 -7
- package/src/filter/filter-consumer-bridge-to-sql-request.js +46 -21
- package/src/filter/filter-interfaces.d.ts +106 -39
- package/src/filter/filter-interfaces.js +312 -32
- package/src/isOfType.d.ts +2 -0
- package/src/isOfType.js +14 -0
- package/src/remult3/Fields.d.ts +36 -0
- package/src/remult3/Fields.js +81 -19
- package/src/remult3/RepositoryImplementation.d.ts +7 -3
- package/src/remult3/RepositoryImplementation.js +106 -71
- package/src/remult3/addValidator.d.ts +2 -0
- package/src/remult3/addValidator.js +20 -0
- package/src/remult3/remult3.d.ts +6 -2
- package/src/remult3/remult3.js +28 -57
- package/src/server-action.d.ts +1 -1
- package/src/server-action.js +5 -4
- package/src/sql-command.d.ts +6 -1
- package/src/validators.d.ts +1 -0
- package/src/validators.js +10 -4
- package/src/valueConverters.js +1 -1
package/remult-knex/index.d.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import type { Knex } from 'knex';
|
|
2
2
|
import type { Remult } from '../src/context.js';
|
|
3
|
+
import { type EntityDbNamesBase } from '../src/filter/filter-consumer-bridge-to-sql-request.js';
|
|
3
4
|
import type { FieldMetadata } from '../src/column-interfaces.js';
|
|
4
5
|
import type { DataProvider, EntityDataProvider } from '../src/data-interfaces.js';
|
|
5
6
|
import type { EntityFilter, EntityMetadata } from '../src/remult3/remult3.js';
|
|
6
7
|
import type { RepositoryOverloads } from '../src/remult3/RepositoryImplementation.js';
|
|
7
|
-
import type { HasWrapIdentifier } from '../src/sql-command.js';
|
|
8
|
-
|
|
8
|
+
import type { HasWrapIdentifier, SqlCommand, SqlCommandFactory, SqlResult } from '../src/sql-command.js';
|
|
9
|
+
import type { CanBuildMigrations } from '../migrations/migration-types.js';
|
|
10
|
+
export declare class KnexDataProvider implements DataProvider, HasWrapIdentifier, SqlCommandFactory, CanBuildMigrations {
|
|
9
11
|
knex: Knex;
|
|
10
12
|
constructor(knex: Knex);
|
|
11
|
-
|
|
13
|
+
end(): Promise<void>;
|
|
14
|
+
createCommand(): SqlCommand;
|
|
15
|
+
execute(sql: string): Promise<SqlResult>;
|
|
16
|
+
static getDb(dataProvider?: DataProvider): Knex<any, any[]>;
|
|
12
17
|
wrapIdentifier: (name: string) => string;
|
|
13
18
|
getEntityDataProvider(entity: EntityMetadata<any>): EntityDataProvider;
|
|
14
19
|
transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;
|
|
15
20
|
static rawFilter(build: CustomKnexFilterBuilderFunction): EntityFilter<any>;
|
|
16
|
-
static filterToRaw<entityType>(entity: RepositoryOverloads<entityType>, condition: EntityFilter<entityType
|
|
21
|
+
static filterToRaw<entityType>(entity: RepositoryOverloads<entityType>, condition: EntityFilter<entityType>, wrapIdentifier?: (name: string) => string): Promise<(knex: any) => void>;
|
|
17
22
|
isProxy?: boolean;
|
|
18
23
|
ensureSchema(entities: EntityMetadata<any>[]): Promise<void>;
|
|
19
24
|
}
|
|
@@ -23,7 +28,9 @@ export declare class KnexSchemaBuilder {
|
|
|
23
28
|
verifyStructureOfAllEntities(remult?: Remult): Promise<void>;
|
|
24
29
|
ensureSchema(entities: EntityMetadata<any>[]): Promise<void>;
|
|
25
30
|
createIfNotExist(entity: EntityMetadata): Promise<void>;
|
|
26
|
-
|
|
31
|
+
createTableKnexCommand(entity: EntityMetadata<any>, e: EntityDbNamesBase): Knex.SchemaBuilder;
|
|
32
|
+
addColumnIfNotExist(entity: EntityMetadata, c: (e: EntityMetadata) => FieldMetadata): Promise<void>;
|
|
33
|
+
createColumnKnexCommand(e: EntityDbNamesBase, col: FieldMetadata<any, any>, colName: string): Knex.SchemaBuilder;
|
|
27
34
|
verifyAllColumns<T extends EntityMetadata>(entity: T): Promise<void>;
|
|
28
35
|
additionalWhere: string;
|
|
29
36
|
constructor(knex: Knex);
|
package/remult-knex/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createKnexDataProvider = exports.buildColumn = exports.KnexSchemaBuilder = exports.KnexDataProvider = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var filter_consumer_bridge_to_sql_request_js_1 = require("../src/filter/filter-consumer-bridge-to-sql-request.js");
|
|
6
|
+
var filter_consumer_bridge_to_sql_request_js_2 = require("../src/filter/filter-consumer-bridge-to-sql-request.js");
|
|
6
7
|
var filter_interfaces_js_1 = require("../src/filter/filter-interfaces.js");
|
|
7
8
|
var CompoundIdField_js_1 = require("../src/CompoundIdField.js");
|
|
8
9
|
var remult_proxy_js_1 = require("../src/remult-proxy.js");
|
|
@@ -18,8 +19,58 @@ var KnexDataProvider = /** @class */ (function () {
|
|
|
18
19
|
this.knex = knex;
|
|
19
20
|
this.wrapIdentifier = function (x) { return _this.knex.ref(x) + ''; };
|
|
20
21
|
}
|
|
21
|
-
KnexDataProvider.
|
|
22
|
-
|
|
22
|
+
KnexDataProvider.prototype.end = function () {
|
|
23
|
+
return this.knex.destroy();
|
|
24
|
+
};
|
|
25
|
+
/* @internal */
|
|
26
|
+
KnexDataProvider.prototype.provideMigrationBuilder = function (builder) {
|
|
27
|
+
var sb = new KnexSchemaBuilder(this.knex);
|
|
28
|
+
return {
|
|
29
|
+
createTable: function (entity) {
|
|
30
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
31
|
+
var e;
|
|
32
|
+
return tslib_1.__generator(this, function (_a) {
|
|
33
|
+
switch (_a.label) {
|
|
34
|
+
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(entity, function (x) { return x; })];
|
|
35
|
+
case 1:
|
|
36
|
+
e = _a.sent();
|
|
37
|
+
sb.createTableKnexCommand(entity, e)
|
|
38
|
+
.toSQL()
|
|
39
|
+
.forEach(function (sql) { return builder.addSql(sql.sql); });
|
|
40
|
+
return [2 /*return*/];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
addColumn: function (entity, field) {
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
47
|
+
var e;
|
|
48
|
+
return tslib_1.__generator(this, function (_a) {
|
|
49
|
+
switch (_a.label) {
|
|
50
|
+
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(entity, function (x) { return x; })];
|
|
51
|
+
case 1:
|
|
52
|
+
e = _a.sent();
|
|
53
|
+
return [4 /*yield*/, sb
|
|
54
|
+
.createColumnKnexCommand(e, field, e.$dbNameOf(field))
|
|
55
|
+
.toSQL()
|
|
56
|
+
.forEach(function (sql) { return builder.addSql(sql.sql); })];
|
|
57
|
+
case 2:
|
|
58
|
+
_a.sent();
|
|
59
|
+
return [2 /*return*/];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
KnexDataProvider.prototype.createCommand = function () {
|
|
67
|
+
return new KnexBridgeToSQLCommand(this.knex);
|
|
68
|
+
};
|
|
69
|
+
KnexDataProvider.prototype.execute = function (sql) {
|
|
70
|
+
return this.createCommand().execute(sql);
|
|
71
|
+
};
|
|
72
|
+
KnexDataProvider.getDb = function (dataProvider) {
|
|
73
|
+
var r = (dataProvider || remult_proxy_js_1.remult.dataProvider);
|
|
23
74
|
if (!r.knex)
|
|
24
75
|
throw 'the data provider is not an KnexDataProvider';
|
|
25
76
|
return r.knex;
|
|
@@ -61,7 +112,7 @@ var KnexDataProvider = /** @class */ (function () {
|
|
|
61
112
|
finally { if (e_2) throw e_2.error; }
|
|
62
113
|
}
|
|
63
114
|
}
|
|
64
|
-
return new KnexEntityDataProvider(entity, this.knex);
|
|
115
|
+
return new KnexEntityDataProvider(entity, this.knex, this.wrapIdentifier);
|
|
65
116
|
};
|
|
66
117
|
KnexDataProvider.prototype.transaction = function (action) {
|
|
67
118
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
@@ -100,7 +151,7 @@ var KnexDataProvider = /** @class */ (function () {
|
|
|
100
151
|
},
|
|
101
152
|
_a;
|
|
102
153
|
};
|
|
103
|
-
KnexDataProvider.filterToRaw = function (entity, condition) {
|
|
154
|
+
KnexDataProvider.filterToRaw = function (entity, condition, wrapIdentifier) {
|
|
104
155
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
105
156
|
var repo, b, _a, r;
|
|
106
157
|
return tslib_1.__generator(this, function (_b) {
|
|
@@ -108,9 +159,9 @@ var KnexDataProvider = /** @class */ (function () {
|
|
|
108
159
|
case 0:
|
|
109
160
|
repo = (0, RepositoryImplementation_js_1.getRepository)(entity);
|
|
110
161
|
_a = FilterConsumerBridgeToKnexRequest.bind;
|
|
111
|
-
return [4 /*yield*/, (0,
|
|
162
|
+
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(repo.metadata, function (x) { return x; })];
|
|
112
163
|
case 1:
|
|
113
|
-
b = new (_a.apply(FilterConsumerBridgeToKnexRequest, [void 0, _b.sent()]))();
|
|
164
|
+
b = new (_a.apply(FilterConsumerBridgeToKnexRequest, [void 0, _b.sent(), wrapIdentifier]))();
|
|
114
165
|
b._addWhere = false;
|
|
115
166
|
return [4 /*yield*/, (0, repository_internals_js_1.getRepositoryInternals)(repo)._translateWhereToFilter(condition)];
|
|
116
167
|
case 2: return [4 /*yield*/, (_b.sent()).__applyToConsumer(b)];
|
|
@@ -143,9 +194,10 @@ var KnexDataProvider = /** @class */ (function () {
|
|
|
143
194
|
}());
|
|
144
195
|
exports.KnexDataProvider = KnexDataProvider;
|
|
145
196
|
var KnexEntityDataProvider = /** @class */ (function () {
|
|
146
|
-
function KnexEntityDataProvider(entity, knex) {
|
|
197
|
+
function KnexEntityDataProvider(entity, knex, rawSqlWrapIdentifier) {
|
|
147
198
|
this.entity = entity;
|
|
148
199
|
this.knex = knex;
|
|
200
|
+
this.rawSqlWrapIdentifier = rawSqlWrapIdentifier;
|
|
149
201
|
}
|
|
150
202
|
KnexEntityDataProvider.prototype.count = function (where) {
|
|
151
203
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
@@ -155,7 +207,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
155
207
|
case 0: return [4 /*yield*/, this.init()];
|
|
156
208
|
case 1:
|
|
157
209
|
e = _a.sent();
|
|
158
|
-
br = new FilterConsumerBridgeToKnexRequest(e);
|
|
210
|
+
br = new FilterConsumerBridgeToKnexRequest(e, this.rawSqlWrapIdentifier);
|
|
159
211
|
where.__applyToConsumer(br);
|
|
160
212
|
return [4 /*yield*/, br.resolveWhere()];
|
|
161
213
|
case 2:
|
|
@@ -208,7 +260,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
208
260
|
}
|
|
209
261
|
query = this.knex(e.$entityName).select(cols);
|
|
210
262
|
if (!(options === null || options === void 0 ? void 0 : options.where)) return [3 /*break*/, 3];
|
|
211
|
-
br = new FilterConsumerBridgeToKnexRequest(e);
|
|
263
|
+
br = new FilterConsumerBridgeToKnexRequest(e, this.rawSqlWrapIdentifier);
|
|
212
264
|
options.where.__applyToConsumer(br);
|
|
213
265
|
return [4 /*yield*/, br.resolveWhere()];
|
|
214
266
|
case 2:
|
|
@@ -257,7 +309,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
257
309
|
var _this = this;
|
|
258
310
|
return tslib_1.__generator(this, function (_a) {
|
|
259
311
|
switch (_a.label) {
|
|
260
|
-
case 0: return [4 /*yield*/, (0,
|
|
312
|
+
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(this.entity, function (x) { return x; })];
|
|
261
313
|
case 1:
|
|
262
314
|
r = (_a.sent());
|
|
263
315
|
return [2 /*return*/, {
|
|
@@ -268,6 +320,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
268
320
|
return r.$dbNameOf(f);
|
|
269
321
|
},
|
|
270
322
|
$entityName: r.$entityName,
|
|
323
|
+
wrapIdentifier: r.wrapIdentifier,
|
|
271
324
|
}];
|
|
272
325
|
}
|
|
273
326
|
});
|
|
@@ -282,7 +335,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
282
335
|
case 0: return [4 /*yield*/, this.init()];
|
|
283
336
|
case 1:
|
|
284
337
|
e = _d.sent();
|
|
285
|
-
f = new FilterConsumerBridgeToKnexRequest(e);
|
|
338
|
+
f = new FilterConsumerBridgeToKnexRequest(e, this.rawSqlWrapIdentifier);
|
|
286
339
|
filter_interfaces_js_1.Filter.fromEntityFilter(this.entity, this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(f);
|
|
287
340
|
resultFilter = this.entity.idMetadata.getIdFilter(id);
|
|
288
341
|
if (data.id != undefined)
|
|
@@ -296,7 +349,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
296
349
|
case 3:
|
|
297
350
|
if (!!_b.done) return [3 /*break*/, 7];
|
|
298
351
|
x = _b.value;
|
|
299
|
-
if (!(0,
|
|
352
|
+
if (!(0, filter_consumer_bridge_to_sql_request_js_2.isDbReadonly)(x, e)) return [3 /*break*/, 4];
|
|
300
353
|
return [3 /*break*/, 6];
|
|
301
354
|
case 4:
|
|
302
355
|
if (!(data[x.key] !== undefined)) return [3 /*break*/, 6];
|
|
@@ -344,7 +397,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
344
397
|
case 0: return [4 /*yield*/, this.init()];
|
|
345
398
|
case 1:
|
|
346
399
|
e = _a.sent();
|
|
347
|
-
f = new FilterConsumerBridgeToKnexRequest(e);
|
|
400
|
+
f = new FilterConsumerBridgeToKnexRequest(e, this.rawSqlWrapIdentifier);
|
|
348
401
|
filter_interfaces_js_1.Filter.fromEntityFilter(this.entity, this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(f);
|
|
349
402
|
return [4 /*yield*/, f.resolveWhere()];
|
|
350
403
|
case 2:
|
|
@@ -382,7 +435,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
382
435
|
case 3:
|
|
383
436
|
if (!!_b.done) return [3 /*break*/, 7];
|
|
384
437
|
x = _b.value;
|
|
385
|
-
if (!(0,
|
|
438
|
+
if (!(0, filter_consumer_bridge_to_sql_request_js_2.isDbReadonly)(x, e)) return [3 /*break*/, 4];
|
|
386
439
|
return [3 /*break*/, 6];
|
|
387
440
|
case 4:
|
|
388
441
|
v = translateValueAndHandleArrayAndHandleArray(x, data[x.key]);
|
|
@@ -440,8 +493,9 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
440
493
|
return KnexEntityDataProvider;
|
|
441
494
|
}());
|
|
442
495
|
var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
443
|
-
function FilterConsumerBridgeToKnexRequest(
|
|
444
|
-
this.
|
|
496
|
+
function FilterConsumerBridgeToKnexRequest(innerNameProvider, rawSqlWrapIdentifier) {
|
|
497
|
+
this.innerNameProvider = innerNameProvider;
|
|
498
|
+
this.rawSqlWrapIdentifier = rawSqlWrapIdentifier;
|
|
445
499
|
this._addWhere = true;
|
|
446
500
|
this.promises = [];
|
|
447
501
|
this.result = [];
|
|
@@ -505,7 +559,7 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
505
559
|
return tslib_1.__generator(this, function (_c) {
|
|
506
560
|
switch (_c.label) {
|
|
507
561
|
case 0:
|
|
508
|
-
f = new FilterConsumerBridgeToKnexRequest(this_1.
|
|
562
|
+
f = new FilterConsumerBridgeToKnexRequest(this_1.innerNameProvider, this_1.rawSqlWrapIdentifier);
|
|
509
563
|
f._addWhere = false;
|
|
510
564
|
element.__applyToConsumer(f);
|
|
511
565
|
return [4 /*yield*/, f.resolveWhere()];
|
|
@@ -564,16 +618,18 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
564
618
|
};
|
|
565
619
|
FilterConsumerBridgeToKnexRequest.prototype.isNull = function (col) {
|
|
566
620
|
var _this = this;
|
|
567
|
-
this.result.push(function (b) { return b.whereNull(_this.
|
|
621
|
+
this.result.push(function (b) { return b.whereNull(_this.innerNameProvider.$dbNameOf(col)); });
|
|
568
622
|
};
|
|
569
623
|
FilterConsumerBridgeToKnexRequest.prototype.isNotNull = function (col) {
|
|
570
624
|
var _this = this;
|
|
571
|
-
this.result.push(function (b) {
|
|
625
|
+
this.result.push(function (b) {
|
|
626
|
+
return b.whereNotNull(_this.innerNameProvider.$dbNameOf(col));
|
|
627
|
+
});
|
|
572
628
|
};
|
|
573
629
|
FilterConsumerBridgeToKnexRequest.prototype.isIn = function (col, val) {
|
|
574
630
|
var _this = this;
|
|
575
631
|
this.result.push(function (knex) {
|
|
576
|
-
return knex.whereIn(_this.
|
|
632
|
+
return knex.whereIn(_this.innerNameProvider.$dbNameOf(col), val.map(function (x) { return translateValueAndHandleArrayAndHandleArray(col, x); }));
|
|
577
633
|
});
|
|
578
634
|
};
|
|
579
635
|
FilterConsumerBridgeToKnexRequest.prototype.isEqualTo = function (col, val) {
|
|
@@ -598,7 +654,7 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
598
654
|
var _this = this;
|
|
599
655
|
this.result.push(function (b) {
|
|
600
656
|
return b.whereRaw('lower (' +
|
|
601
|
-
b.client.ref(_this.
|
|
657
|
+
b.client.ref(_this.innerNameProvider.$dbNameOf(col)) +
|
|
602
658
|
") like lower ('%" +
|
|
603
659
|
val.replace(/'/g, "''") +
|
|
604
660
|
"%')");
|
|
@@ -611,7 +667,7 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
611
667
|
var _this = this;
|
|
612
668
|
this.result.push(function (b) {
|
|
613
669
|
return b.whereRaw('not lower (' +
|
|
614
|
-
b.client.ref(_this.
|
|
670
|
+
b.client.ref(_this.innerNameProvider.$dbNameOf(col)) +
|
|
615
671
|
") like lower ('%" +
|
|
616
672
|
val.replace(/'/g, "''") +
|
|
617
673
|
"%')");
|
|
@@ -623,13 +679,13 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
623
679
|
FilterConsumerBridgeToKnexRequest.prototype.add = function (col, val, operator) {
|
|
624
680
|
var _this = this;
|
|
625
681
|
this.result.push(function (b) {
|
|
626
|
-
return b.where(_this.
|
|
682
|
+
return b.where(_this.innerNameProvider.$dbNameOf(col), operator, translateValueAndHandleArrayAndHandleArray(col, val));
|
|
627
683
|
});
|
|
628
684
|
};
|
|
629
685
|
FilterConsumerBridgeToKnexRequest.prototype.databaseCustom = function (databaseCustom) {
|
|
630
686
|
var _this = this;
|
|
631
687
|
this.promises.push((function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
632
|
-
var _a, _b;
|
|
688
|
+
var _a, _b, r_2, item, sql_1;
|
|
633
689
|
return tslib_1.__generator(this, function (_c) {
|
|
634
690
|
switch (_c.label) {
|
|
635
691
|
case 0:
|
|
@@ -639,7 +695,20 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
639
695
|
case 1:
|
|
640
696
|
_b.apply(_a, [_c.sent()]);
|
|
641
697
|
_c.label = 2;
|
|
642
|
-
case 2:
|
|
698
|
+
case 2:
|
|
699
|
+
if (!(databaseCustom === null || databaseCustom === void 0 ? void 0 : databaseCustom.buildSql)) return [3 /*break*/, 4];
|
|
700
|
+
r_2 = new KnexCommandHelper();
|
|
701
|
+
item = new filter_consumer_bridge_to_sql_request_js_1.CustomSqlFilterBuilder(r_2, this.rawSqlWrapIdentifier);
|
|
702
|
+
return [4 /*yield*/, databaseCustom.buildSql(item)];
|
|
703
|
+
case 3:
|
|
704
|
+
sql_1 = _c.sent();
|
|
705
|
+
if (typeof sql_1 !== 'string')
|
|
706
|
+
sql_1 = item.sql;
|
|
707
|
+
if (sql_1) {
|
|
708
|
+
this.result.push(function (b) { return b.whereRaw(sql_1, r_2.values); });
|
|
709
|
+
}
|
|
710
|
+
_c.label = 4;
|
|
711
|
+
case 4: return [2 /*return*/];
|
|
643
712
|
}
|
|
644
713
|
});
|
|
645
714
|
}); })());
|
|
@@ -681,14 +750,13 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
681
750
|
case 1:
|
|
682
751
|
if (!!entities_1_1.done) return [3 /*break*/, 9];
|
|
683
752
|
entity = entities_1_1.value;
|
|
684
|
-
return [4 /*yield*/, (0,
|
|
753
|
+
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(entity, function (x) { return x; })];
|
|
685
754
|
case 2:
|
|
686
755
|
e = _b.sent();
|
|
687
756
|
_b.label = 3;
|
|
688
757
|
case 3:
|
|
689
758
|
_b.trys.push([3, 7, , 8]);
|
|
690
|
-
if (
|
|
691
|
-
if (!(e.$entityName.toLowerCase().indexOf('from ') < 0)) return [3 /*break*/, 6];
|
|
759
|
+
if (!(0, filter_consumer_bridge_to_sql_request_js_2.shouldCreateEntity)(entity, e)) return [3 /*break*/, 6];
|
|
692
760
|
return [4 /*yield*/, this.createIfNotExist(entity)];
|
|
693
761
|
case 4:
|
|
694
762
|
_b.sent();
|
|
@@ -722,85 +790,85 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
722
790
|
};
|
|
723
791
|
KnexSchemaBuilder.prototype.createIfNotExist = function (entity) {
|
|
724
792
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
725
|
-
var e
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
switch (_d.label) {
|
|
730
|
-
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity, function (x) { return x; })];
|
|
793
|
+
var e;
|
|
794
|
+
return tslib_1.__generator(this, function (_a) {
|
|
795
|
+
switch (_a.label) {
|
|
796
|
+
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(entity, function (x) { return x; })];
|
|
731
797
|
case 1:
|
|
732
|
-
e =
|
|
798
|
+
e = _a.sent();
|
|
733
799
|
return [4 /*yield*/, this.knex.schema.hasTable(e.$entityName)];
|
|
734
800
|
case 2:
|
|
735
|
-
if (!!(
|
|
736
|
-
|
|
737
|
-
try {
|
|
738
|
-
for (_a = tslib_1.__values(entity.fields), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
739
|
-
f = _b.value;
|
|
740
|
-
cols_1.set(f, {
|
|
741
|
-
name: e.$dbNameOf(f),
|
|
742
|
-
readonly: (0, filter_consumer_bridge_to_sql_request_js_1.shouldNotCreateField)(f, e),
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
747
|
-
finally {
|
|
748
|
-
try {
|
|
749
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
750
|
-
}
|
|
751
|
-
finally { if (e_9) throw e_9.error; }
|
|
752
|
-
}
|
|
753
|
-
return [4 /*yield*/, logSql(this.knex.schema.createTable(e.$entityName, function (b) {
|
|
754
|
-
var e_10, _a;
|
|
755
|
-
try {
|
|
756
|
-
for (var _b = tslib_1.__values(entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
757
|
-
var x = _c.value;
|
|
758
|
-
if (!cols_1.get(x).readonly || (0, RepositoryImplementation_js_1.isAutoIncrement)(x)) {
|
|
759
|
-
if ((0, RepositoryImplementation_js_1.isAutoIncrement)(x))
|
|
760
|
-
b.increments(cols_1.get(x).name);
|
|
761
|
-
else {
|
|
762
|
-
buildColumn(x, cols_1.get(x).name, b, supportsJsonDataStorage(_this.knex));
|
|
763
|
-
if (x == entity.idMetadata.field)
|
|
764
|
-
b.primary([cols_1.get(x).name]);
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
770
|
-
finally {
|
|
771
|
-
try {
|
|
772
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
773
|
-
}
|
|
774
|
-
finally { if (e_10) throw e_10.error; }
|
|
775
|
-
}
|
|
776
|
-
}))];
|
|
801
|
+
if (!!(_a.sent())) return [3 /*break*/, 4];
|
|
802
|
+
return [4 /*yield*/, logSql(this.createTableKnexCommand(entity, e))];
|
|
777
803
|
case 3:
|
|
778
|
-
|
|
779
|
-
|
|
804
|
+
_a.sent();
|
|
805
|
+
_a.label = 4;
|
|
780
806
|
case 4: return [2 /*return*/];
|
|
781
807
|
}
|
|
782
808
|
});
|
|
783
809
|
});
|
|
784
810
|
};
|
|
811
|
+
KnexSchemaBuilder.prototype.createTableKnexCommand = function (entity, e) {
|
|
812
|
+
var e_9, _a;
|
|
813
|
+
var _this = this;
|
|
814
|
+
var cols = new Map();
|
|
815
|
+
try {
|
|
816
|
+
for (var _b = tslib_1.__values(entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
817
|
+
var f = _c.value;
|
|
818
|
+
cols.set(f, {
|
|
819
|
+
name: e.$dbNameOf(f),
|
|
820
|
+
readonly: (0, filter_consumer_bridge_to_sql_request_js_2.shouldNotCreateField)(f, e),
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
825
|
+
finally {
|
|
826
|
+
try {
|
|
827
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
828
|
+
}
|
|
829
|
+
finally { if (e_9) throw e_9.error; }
|
|
830
|
+
}
|
|
831
|
+
return this.knex.schema.createTable(e.$entityName, function (b) {
|
|
832
|
+
var e_10, _a;
|
|
833
|
+
try {
|
|
834
|
+
for (var _b = tslib_1.__values(entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
835
|
+
var x = _c.value;
|
|
836
|
+
if (!cols.get(x).readonly || (0, RepositoryImplementation_js_1.isAutoIncrement)(x)) {
|
|
837
|
+
if ((0, RepositoryImplementation_js_1.isAutoIncrement)(x))
|
|
838
|
+
b.increments(cols.get(x).name);
|
|
839
|
+
else {
|
|
840
|
+
buildColumn(x, cols.get(x).name, b, supportsJsonDataStorage(_this.knex));
|
|
841
|
+
if (x == entity.idMetadata.field)
|
|
842
|
+
b.primary([cols.get(x).name]);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
848
|
+
finally {
|
|
849
|
+
try {
|
|
850
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
851
|
+
}
|
|
852
|
+
finally { if (e_10) throw e_10.error; }
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
};
|
|
785
856
|
KnexSchemaBuilder.prototype.addColumnIfNotExist = function (entity, c) {
|
|
786
857
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
787
858
|
var e, col, colName;
|
|
788
|
-
var _this = this;
|
|
789
859
|
return tslib_1.__generator(this, function (_a) {
|
|
790
860
|
switch (_a.label) {
|
|
791
|
-
case 0: return [4 /*yield*/, (0,
|
|
861
|
+
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(entity, function (x) { return x; })];
|
|
792
862
|
case 1:
|
|
793
863
|
e = _a.sent();
|
|
794
|
-
if ((0,
|
|
864
|
+
if ((0, filter_consumer_bridge_to_sql_request_js_2.shouldNotCreateField)(c(entity), e))
|
|
795
865
|
return [2 /*return*/];
|
|
796
866
|
col = c(entity);
|
|
797
867
|
colName = e.$dbNameOf(col);
|
|
798
868
|
return [4 /*yield*/, this.knex.schema.hasColumn(e.$entityName, colName)];
|
|
799
869
|
case 2:
|
|
800
870
|
if (!!(_a.sent())) return [3 /*break*/, 4];
|
|
801
|
-
return [4 /*yield*/, logSql(this.
|
|
802
|
-
buildColumn(col, colName, b, supportsJsonDataStorage(_this.knex));
|
|
803
|
-
}))];
|
|
871
|
+
return [4 /*yield*/, logSql(this.createColumnKnexCommand(e, col, colName))];
|
|
804
872
|
case 3:
|
|
805
873
|
_a.sent();
|
|
806
874
|
_a.label = 4;
|
|
@@ -809,13 +877,19 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
809
877
|
});
|
|
810
878
|
});
|
|
811
879
|
};
|
|
880
|
+
KnexSchemaBuilder.prototype.createColumnKnexCommand = function (e, col, colName) {
|
|
881
|
+
var _this = this;
|
|
882
|
+
return this.knex.schema.alterTable(e.$entityName, function (b) {
|
|
883
|
+
buildColumn(col, colName, b, supportsJsonDataStorage(_this.knex));
|
|
884
|
+
});
|
|
885
|
+
};
|
|
812
886
|
KnexSchemaBuilder.prototype.verifyAllColumns = function (entity) {
|
|
813
887
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
814
888
|
var e, _loop_2, this_2, _a, _b, col, e_11_1, err_3;
|
|
815
889
|
var e_11, _c;
|
|
816
890
|
return tslib_1.__generator(this, function (_d) {
|
|
817
891
|
switch (_d.label) {
|
|
818
|
-
case 0: return [4 /*yield*/, (0,
|
|
892
|
+
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(entity, function (x) { return x; })];
|
|
819
893
|
case 1:
|
|
820
894
|
e = _d.sent();
|
|
821
895
|
_d.label = 2;
|
|
@@ -825,7 +899,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
825
899
|
return tslib_1.__generator(this, function (_e) {
|
|
826
900
|
switch (_e.label) {
|
|
827
901
|
case 0:
|
|
828
|
-
if (!!(0,
|
|
902
|
+
if (!!(0, filter_consumer_bridge_to_sql_request_js_2.shouldNotCreateField)(col, e)) return [3 /*break*/, 2];
|
|
829
903
|
return [4 /*yield*/, this_2.addColumnIfNotExist(entity, function () { return col; })];
|
|
830
904
|
case 1:
|
|
831
905
|
_e.sent();
|
|
@@ -934,16 +1008,24 @@ function buildColumn(x, dbName, b, supportsJson) {
|
|
|
934
1008
|
else if (x.valueConverter.fieldTypeInDb == 'json')
|
|
935
1009
|
if (supportsJson)
|
|
936
1010
|
b.json(dbName);
|
|
937
|
-
else
|
|
938
|
-
b.text(dbName);
|
|
1011
|
+
else {
|
|
1012
|
+
var c = b.text(dbName);
|
|
1013
|
+
if (!x.allowNull)
|
|
1014
|
+
c.defaultTo('').notNullable();
|
|
1015
|
+
}
|
|
939
1016
|
else
|
|
940
1017
|
b.specificType(dbName, x.valueConverter.fieldTypeInDb);
|
|
941
1018
|
}
|
|
942
|
-
else {
|
|
1019
|
+
else if (x.valueType === String) {
|
|
943
1020
|
var c = b.string(dbName, x.options.maxLength);
|
|
944
1021
|
if (!x.allowNull)
|
|
945
1022
|
c.defaultTo('').notNullable();
|
|
946
1023
|
}
|
|
1024
|
+
else {
|
|
1025
|
+
var c = b.text(dbName);
|
|
1026
|
+
if (!x.allowNull)
|
|
1027
|
+
c.defaultTo('').notNullable();
|
|
1028
|
+
}
|
|
947
1029
|
}
|
|
948
1030
|
exports.buildColumn = buildColumn;
|
|
949
1031
|
function logSql(who) {
|
|
@@ -972,3 +1054,88 @@ function translateValueAndHandleArrayAndHandleArray(field, val) {
|
|
|
972
1054
|
return JSON.stringify(result);
|
|
973
1055
|
return result;
|
|
974
1056
|
}
|
|
1057
|
+
var KnexCommandHelper = /** @class */ (function () {
|
|
1058
|
+
function KnexCommandHelper() {
|
|
1059
|
+
this.values = {};
|
|
1060
|
+
this.i = 0;
|
|
1061
|
+
}
|
|
1062
|
+
KnexCommandHelper.prototype.addParameterAndReturnSqlToken = function (val) {
|
|
1063
|
+
return this.param(val);
|
|
1064
|
+
};
|
|
1065
|
+
KnexCommandHelper.prototype.param = function (val) {
|
|
1066
|
+
if (Array.isArray(val))
|
|
1067
|
+
val = JSON.stringify(val);
|
|
1068
|
+
var key = ':' + this.i++;
|
|
1069
|
+
this.values[key.substring(1)] = val;
|
|
1070
|
+
return key;
|
|
1071
|
+
};
|
|
1072
|
+
return KnexCommandHelper;
|
|
1073
|
+
}());
|
|
1074
|
+
var KnexBridgeToSQLCommand = /** @class */ (function (_super) {
|
|
1075
|
+
tslib_1.__extends(KnexBridgeToSQLCommand, _super);
|
|
1076
|
+
function KnexBridgeToSQLCommand(source) {
|
|
1077
|
+
var _this = _super.call(this) || this;
|
|
1078
|
+
_this.source = source;
|
|
1079
|
+
_this.values = {};
|
|
1080
|
+
_this.i = 0;
|
|
1081
|
+
return _this;
|
|
1082
|
+
}
|
|
1083
|
+
KnexBridgeToSQLCommand.prototype.addParameterAndReturnSqlToken = function (val) {
|
|
1084
|
+
return this.param(val);
|
|
1085
|
+
};
|
|
1086
|
+
KnexBridgeToSQLCommand.prototype.param = function (val) {
|
|
1087
|
+
if (Array.isArray(val))
|
|
1088
|
+
val = JSON.stringify(val);
|
|
1089
|
+
var key = ':' + this.i++;
|
|
1090
|
+
this.values[key.substring(1)] = val;
|
|
1091
|
+
return key;
|
|
1092
|
+
};
|
|
1093
|
+
KnexBridgeToSQLCommand.prototype.execute = function (sql) {
|
|
1094
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1095
|
+
var _this = this;
|
|
1096
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1097
|
+
switch (_a.label) {
|
|
1098
|
+
case 0: return [4 /*yield*/, this.source.raw(sql, this.values).then(function (r) {
|
|
1099
|
+
switch (_this.source.client.config.client) {
|
|
1100
|
+
case 'mysql':
|
|
1101
|
+
case 'mysql2':
|
|
1102
|
+
return new KnexPostgresBridgeToSQLQueryResult({
|
|
1103
|
+
fields: r[1],
|
|
1104
|
+
rows: r[0],
|
|
1105
|
+
});
|
|
1106
|
+
case 'pg':
|
|
1107
|
+
return new KnexPostgresBridgeToSQLQueryResult(r);
|
|
1108
|
+
default:
|
|
1109
|
+
case 'better-sqlite3':
|
|
1110
|
+
case 'mssql':
|
|
1111
|
+
return new KnexPostgresBridgeToSQLQueryResult({
|
|
1112
|
+
rows: r,
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
})];
|
|
1116
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
});
|
|
1120
|
+
};
|
|
1121
|
+
return KnexBridgeToSQLCommand;
|
|
1122
|
+
}(KnexCommandHelper));
|
|
1123
|
+
var KnexPostgresBridgeToSQLQueryResult = /** @class */ (function () {
|
|
1124
|
+
function KnexPostgresBridgeToSQLQueryResult(r) {
|
|
1125
|
+
this.r = r;
|
|
1126
|
+
this.rows = r.rows;
|
|
1127
|
+
}
|
|
1128
|
+
KnexPostgresBridgeToSQLQueryResult.prototype.getColumnKeyInResultForIndexInSelect = function (index) {
|
|
1129
|
+
if (this.r.fields)
|
|
1130
|
+
return this.r.fields[index].name;
|
|
1131
|
+
if (this.rows.length == 0)
|
|
1132
|
+
throw Error('No rows');
|
|
1133
|
+
var i = 0;
|
|
1134
|
+
for (var m in this.rows[0]) {
|
|
1135
|
+
if (i++ == index)
|
|
1136
|
+
return m;
|
|
1137
|
+
}
|
|
1138
|
+
throw Error('index not found');
|
|
1139
|
+
};
|
|
1140
|
+
return KnexPostgresBridgeToSQLQueryResult;
|
|
1141
|
+
}());
|
package/remult-mongo.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ClientSession, type Db, type MongoClient } from 'mongodb';
|
|
2
|
-
import type { DataProvider, EntityDataProvider, EntityFilter, EntityMetadata
|
|
2
|
+
import type { DataProvider, EntityDataProvider, EntityFilter, EntityMetadata } from './index.js';
|
|
3
3
|
import type { RepositoryOverloads } from './src/remult3/RepositoryImplementation.js';
|
|
4
4
|
export declare class MongoDataProvider implements DataProvider {
|
|
5
5
|
private db;
|
|
@@ -10,7 +10,7 @@ export declare class MongoDataProvider implements DataProvider {
|
|
|
10
10
|
});
|
|
11
11
|
session?: ClientSession;
|
|
12
12
|
disableTransactions: boolean;
|
|
13
|
-
static getDb(
|
|
13
|
+
static getDb(dataProvider?: DataProvider): {
|
|
14
14
|
db: Db;
|
|
15
15
|
session: ClientSession;
|
|
16
16
|
};
|
package/remult-mongo.js
CHANGED
|
@@ -17,8 +17,8 @@ var MongoDataProvider = /** @class */ (function () {
|
|
|
17
17
|
this.session = options === null || options === void 0 ? void 0 : options.session;
|
|
18
18
|
this.disableTransactions = Boolean(options === null || options === void 0 ? void 0 : options.disableTransactions);
|
|
19
19
|
}
|
|
20
|
-
MongoDataProvider.getDb = function (
|
|
21
|
-
var r = (
|
|
20
|
+
MongoDataProvider.getDb = function (dataProvider) {
|
|
21
|
+
var r = (dataProvider || remult_proxy_js_1.remult.dataProvider);
|
|
22
22
|
if (!r.db)
|
|
23
23
|
throw 'the data provider is not a MongoDataProvider';
|
|
24
24
|
return { db: r.db, session: r.session };
|