@thisisagile/easy-mongo 7.9.1 → 7.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Collection.d.ts +2 -0
- package/dist/Collection.js +4 -0
- package/dist/Collection.js.map +1 -1
- package/dist/MongoGateway.js +1 -1
- package/dist/MongoGateway.js.map +1 -1
- package/package.json +3 -3
- package/src/Collection.ts +5 -0
- package/src/MongoGateway.ts +1 -1
package/README.md
CHANGED
|
@@ -227,7 +227,7 @@ Because data in existing databases rarely supplies the format you need in your s
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
The `Map
|
|
230
|
+
The `Map` and `Table` classes have a property called `db` that represents the database to connect to. This is usually an instance of the `Database` enumeration, which in its turn defines the database (and its provider) to connect to, as in the example below.
|
|
231
231
|
|
|
232
232
|
export class MyDatabase extends Database {
|
|
233
233
|
static readonly Erp = new Database('openerp', PostgreSqlProvider);
|
package/dist/Collection.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Condition, Database, Field, Json, MapOptions, Mapper, PropertyOptions, Text } from '@thisisagile/easy';
|
|
2
|
+
import { MongoProvider } from './MongoProvider';
|
|
2
3
|
export declare class Collection extends Mapper {
|
|
3
4
|
protected readonly map: {
|
|
4
5
|
field: <T = unknown>(name: string, options?: PropertyOptions<T> | undefined) => Field;
|
|
@@ -12,6 +13,7 @@ export declare class Collection extends Mapper {
|
|
|
12
13
|
};
|
|
13
14
|
constructor(options?: MapOptions);
|
|
14
15
|
get db(): Database;
|
|
16
|
+
get provider(): MongoProvider;
|
|
15
17
|
readonly id: Field;
|
|
16
18
|
where: (...conditions: Condition[]) => Json;
|
|
17
19
|
google: (value: unknown) => Condition;
|
package/dist/Collection.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Collection = void 0;
|
|
4
4
|
const easy_1 = require("@thisisagile/easy");
|
|
5
5
|
const Utils_1 = require("./Utils");
|
|
6
|
+
const MongoProvider_1 = require("./MongoProvider");
|
|
6
7
|
class Collection extends easy_1.Mapper {
|
|
7
8
|
constructor(options = { startFrom: 'source' }) {
|
|
8
9
|
super(options);
|
|
@@ -18,6 +19,9 @@ class Collection extends easy_1.Mapper {
|
|
|
18
19
|
get db() {
|
|
19
20
|
return easy_1.Database.Default;
|
|
20
21
|
}
|
|
22
|
+
get provider() {
|
|
23
|
+
return new MongoProvider_1.MongoProvider(this);
|
|
24
|
+
}
|
|
21
25
|
out(to = {}) {
|
|
22
26
|
return Utils_1.toMongoType(super.out(to));
|
|
23
27
|
}
|
package/dist/Collection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.js","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":";;;AAAA,4CAc2B;AAC3B,mCAAsC;
|
|
1
|
+
{"version":3,"file":"Collection.js","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":";;;AAAA,4CAc2B;AAC3B,mCAAsC;AACtC,mDAAgD;AAEhD,MAAa,UAAW,SAAQ,aAAM;IAMpC,YAAY,UAAsB,EAAE,SAAS,EAAE,QAAQ,EAAE;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QANE,QAAG,GAAG;YACvB,GAAG,eAAQ;YACX,KAAK,EAAE,CAAc,IAAY,EAAE,OAA4B,EAAS,EAAE,CAAC,IAAI,YAAK,CAAC,IAAI,EAAE,OAAO,CAAC;SACpG,CAAC;QAcO,OAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,aAAM,EAAE,CAAC,CAAC;QAErD,UAAK,GAAG,CAAC,GAAG,UAAuB,EAAQ,EAAE,CAAC,IAAI,uBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC;QAE/F,WAAM,GAAG,CAAC,KAAc,EAAa,EAAE,CAAC,kBAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAE9E,WAAM,GAAG,CAAC,GAAS,EAAS,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,eAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAhB7D,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,eAAQ,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,6BAAa,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAUD,GAAG,CAAC,KAAW,EAAE;QACf,OAAO,mBAAW,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;CACF;AA7BD,gCA6BC"}
|
package/dist/MongoGateway.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MongoGateway = void 0;
|
|
4
4
|
const easy_1 = require("@thisisagile/easy");
|
|
5
5
|
class MongoGateway {
|
|
6
|
-
constructor(collection, provider =
|
|
6
|
+
constructor(collection, provider = collection.provider) {
|
|
7
7
|
this.collection = collection;
|
|
8
8
|
this.provider = provider;
|
|
9
9
|
}
|
package/dist/MongoGateway.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoGateway.js","sourceRoot":"","sources":["../src/MongoGateway.ts"],"names":[],"mappings":";;;AACA,4CAAkI;AAGlI,MAAa,YAAY;IACvB,YAAqB,UAAsB,EAAW,WAA0B,
|
|
1
|
+
{"version":3,"file":"MongoGateway.js","sourceRoot":"","sources":["../src/MongoGateway.ts"],"names":[],"mappings":";;;AACA,4CAAkI;AAGlI,MAAa,YAAY;IACvB,YAAqB,UAAsB,EAAW,WAA0B,UAAU,CAAC,QAAQ;QAA9E,eAAU,GAAV,UAAU,CAAY;QAAW,aAAQ,GAAR,QAAQ,CAAqC;IAAG,CAAC;IAEv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AI,CAAC,CAAC,CAAC,EAAE,CAAC,gBAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,GAAG,CAAC,IAAU;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,CAAC,IAAU;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED,MAAM,CAAC,EAAM;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;CACF;AAtCD,oCAsCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy-mongo",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.10.7",
|
|
4
4
|
"description": "Add support for MongoDB",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@thisisagile/easy-test": "7.
|
|
34
|
+
"@thisisagile/easy-test": "7.10.7"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thisisagile/easy": "7.
|
|
37
|
+
"@thisisagile/easy": "7.10.7",
|
|
38
38
|
"@types/mongodb": "^3.6.18",
|
|
39
39
|
"mongodb": "^3.6.9"
|
|
40
40
|
}
|
package/src/Collection.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
toUuid,
|
|
15
15
|
} from '@thisisagile/easy';
|
|
16
16
|
import { toMongoType } from './Utils';
|
|
17
|
+
import { MongoProvider } from './MongoProvider';
|
|
17
18
|
|
|
18
19
|
export class Collection extends Mapper {
|
|
19
20
|
protected readonly map = {
|
|
@@ -29,6 +30,10 @@ export class Collection extends Mapper {
|
|
|
29
30
|
return Database.Default;
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
get provider(): MongoProvider {
|
|
34
|
+
return new MongoProvider(this);
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
readonly id = this.map.field('id', { dflt: toUuid });
|
|
33
38
|
|
|
34
39
|
where = (...conditions: Condition[]): Json => new LogicalCondition('and', conditions).toJSON();
|
package/src/MongoGateway.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { asJson, Condition, Gateway, Id, ifDefined, isDefined, Json, JsonValue,
|
|
|
3
3
|
import { Collection } from './Collection';
|
|
4
4
|
|
|
5
5
|
export class MongoGateway implements Gateway {
|
|
6
|
-
constructor(readonly collection: Collection, readonly provider: MongoProvider =
|
|
6
|
+
constructor(readonly collection: Collection, readonly provider: MongoProvider = collection.provider) {}
|
|
7
7
|
|
|
8
8
|
all(): Promise<List<Json>> {
|
|
9
9
|
return this.provider.all().then(l => l.map(j => this.collection.in(j)));
|