@orion-js/mongodb 3.3.8 → 3.3.9
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.
|
@@ -55,3 +55,30 @@ it('generates a ids with a prefix', async () => {
|
|
|
55
55
|
await Tests.updateOne({ _id: 'pref_123' }, { $set: { name: 'Nicolás' } });
|
|
56
56
|
expect(userId).toMatch(/^pref_/);
|
|
57
57
|
});
|
|
58
|
+
it('generates a ids with a distinct type', async () => {
|
|
59
|
+
let Schema = class Schema {
|
|
60
|
+
};
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, typed_model_1.Prop)(),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], Schema.prototype, "_id", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, typed_model_1.Prop)(),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], Schema.prototype, "name", void 0);
|
|
69
|
+
Schema = __decorate([
|
|
70
|
+
(0, typed_model_1.TypedSchema)()
|
|
71
|
+
], Schema);
|
|
72
|
+
const Tests = (0, index_1.default)({
|
|
73
|
+
name: (0, helpers_1.generateId)(),
|
|
74
|
+
schema: Schema
|
|
75
|
+
});
|
|
76
|
+
const userId = await Tests.insertOne({
|
|
77
|
+
name: 'Nico'
|
|
78
|
+
});
|
|
79
|
+
await Tests.findOne(userId);
|
|
80
|
+
// This should throw an error
|
|
81
|
+
// await Tests.findOne(anId)
|
|
82
|
+
const anId = '123';
|
|
83
|
+
await Tests.findOne(anId);
|
|
84
|
+
});
|
package/lib/types/index.d.ts
CHANGED
|
@@ -166,4 +166,7 @@ export interface Collection<ModelClass extends ModelClassBase = ModelClassBase>
|
|
|
166
166
|
createIndexesPromise: Promise<string[]>;
|
|
167
167
|
connectionPromise: Promise<MongoDB.MongoClient>;
|
|
168
168
|
}
|
|
169
|
+
export declare type DistinctDocumentId<DistinctId extends string> = string & {
|
|
170
|
+
__TYPE__: `DistinctDocumentId<${DistinctId}>`;
|
|
171
|
+
};
|
|
169
172
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/mongodb",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.9",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"@orion-js/env": "^3.3.6",
|
|
21
21
|
"@orion-js/helpers": "^3.3.6",
|
|
22
22
|
"@orion-js/logger": "^3.3.6",
|
|
23
|
-
"@orion-js/models": "^3.3.
|
|
24
|
-
"@orion-js/resolvers": "^3.3.
|
|
25
|
-
"@orion-js/schema": "^3.3.
|
|
23
|
+
"@orion-js/models": "^3.3.9",
|
|
24
|
+
"@orion-js/resolvers": "^3.3.9",
|
|
25
|
+
"@orion-js/schema": "^3.3.9",
|
|
26
26
|
"@orion-js/services": "^3.3.6",
|
|
27
|
-
"@orion-js/typed-model": "^3.3.
|
|
27
|
+
"@orion-js/typed-model": "^3.3.9",
|
|
28
28
|
"dataloader": "2.1.0",
|
|
29
29
|
"dot-object": "2.1.4",
|
|
30
30
|
"mongodb": "4.5.0"
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "c9591d61fe15eb98c6b6d5c3773afab11c412e42"
|
|
45
45
|
}
|