@orion-js/mongodb 3.11.8 → 3.12.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 +15 -0
- package/dist/index.cjs +81990 -0
- package/dist/index.d.ts +204 -0
- package/dist/index.js +81964 -0
- package/package.json +29 -27
- package/LICENSE +0 -21
- package/lib/connect/connections.d.ts +0 -13
- package/lib/connect/connections.js +0 -4
- package/lib/connect/getDBName.d.ts +0 -1
- package/lib/connect/getDBName.js +0 -23
- package/lib/connect/getMongoConnection.d.ts +0 -8
- package/lib/connect/getMongoConnection.js +0 -47
- package/lib/connect/getMongoConnection.test.d.ts +0 -1
- package/lib/connect/getMongoConnection.test.js +0 -43
- package/lib/connect/getMongoURLFromEnv.d.ts +0 -1
- package/lib/connect/getMongoURLFromEnv.js +0 -21
- package/lib/connect/index.d.ts +0 -4
- package/lib/connect/index.js +0 -8
- package/lib/createCollection/createIndexPromisesTest.d.ts +0 -1
- package/lib/createCollection/createIndexPromisesTest.js +0 -12
- package/lib/createCollection/createIndexes.d.ts +0 -3
- package/lib/createCollection/createIndexes.js +0 -67
- package/lib/createCollection/createIndexes.test.d.ts +0 -1
- package/lib/createCollection/createIndexes.test.js +0 -91
- package/lib/createCollection/createIndexesPromise.test.d.ts +0 -1
- package/lib/createCollection/createIndexesPromise.test.js +0 -32
- package/lib/createCollection/generateId.d.ts +0 -3
- package/lib/createCollection/generateId.js +0 -25
- package/lib/createCollection/generateId.test.d.ts +0 -1
- package/lib/createCollection/generateId.test.js +0 -108
- package/lib/createCollection/getMethods/aggregate.test.d.ts +0 -1
- package/lib/createCollection/getMethods/aggregate.test.js +0 -20
- package/lib/createCollection/getMethods/cleanModifier.d.ts +0 -4
- package/lib/createCollection/getMethods/cleanModifier.js +0 -75
- package/lib/createCollection/getMethods/cleanModifier.test.d.ts +0 -1
- package/lib/createCollection/getMethods/cleanModifier.test.js +0 -186
- package/lib/createCollection/getMethods/countDocuments.d.ts +0 -2
- package/lib/createCollection/getMethods/countDocuments.js +0 -16
- package/lib/createCollection/getMethods/countDocuments.test.d.ts +0 -1
- package/lib/createCollection/getMethods/countDocuments.test.js +0 -21
- package/lib/createCollection/getMethods/dataLoader/dataLoad/getDataLoader.d.ts +0 -9
- package/lib/createCollection/getMethods/dataLoader/dataLoad/getDataLoader.js +0 -25
- package/lib/createCollection/getMethods/dataLoader/dataLoad/getDataLoader.test.d.ts +0 -1
- package/lib/createCollection/getMethods/dataLoader/dataLoad/getDataLoader.test.js +0 -37
- package/lib/createCollection/getMethods/dataLoader/dataLoad/index.d.ts +0 -9
- package/lib/createCollection/getMethods/dataLoader/dataLoad/index.js +0 -21
- package/lib/createCollection/getMethods/dataLoader/index.d.ts +0 -5
- package/lib/createCollection/getMethods/dataLoader/index.js +0 -14
- package/lib/createCollection/getMethods/dataLoader/loadById.d.ts +0 -2
- package/lib/createCollection/getMethods/dataLoader/loadById.js +0 -13
- package/lib/createCollection/getMethods/dataLoader/loadById.test.d.ts +0 -1
- package/lib/createCollection/getMethods/dataLoader/loadById.test.js +0 -23
- package/lib/createCollection/getMethods/dataLoader/loadData.d.ts +0 -2
- package/lib/createCollection/getMethods/dataLoader/loadData.js +0 -49
- package/lib/createCollection/getMethods/dataLoader/loadMany.d.ts +0 -2
- package/lib/createCollection/getMethods/dataLoader/loadMany.js +0 -10
- package/lib/createCollection/getMethods/dataLoader/loadMany.test.d.ts +0 -1
- package/lib/createCollection/getMethods/dataLoader/loadMany.test.js +0 -85
- package/lib/createCollection/getMethods/dataLoader/loadOne.d.ts +0 -2
- package/lib/createCollection/getMethods/dataLoader/loadOne.js +0 -10
- package/lib/createCollection/getMethods/dataLoader/loadOne.test.d.ts +0 -1
- package/lib/createCollection/getMethods/dataLoader/loadOne.test.js +0 -76
- package/lib/createCollection/getMethods/deleteMany.d.ts +0 -2
- package/lib/createCollection/getMethods/deleteMany.js +0 -16
- package/lib/createCollection/getMethods/deleteOne.d.ts +0 -2
- package/lib/createCollection/getMethods/deleteOne.js +0 -16
- package/lib/createCollection/getMethods/estimatedDocumentCount.d.ts +0 -3
- package/lib/createCollection/getMethods/estimatedDocumentCount.js +0 -10
- package/lib/createCollection/getMethods/estimatedDocumentCount.test.d.ts +0 -1
- package/lib/createCollection/getMethods/estimatedDocumentCount.test.js +0 -15
- package/lib/createCollection/getMethods/find.d.ts +0 -2
- package/lib/createCollection/getMethods/find.js +0 -21
- package/lib/createCollection/getMethods/findOne.d.ts +0 -2
- package/lib/createCollection/getMethods/findOne.js +0 -18
- package/lib/createCollection/getMethods/findOneAndUpdate.d.ts +0 -3
- package/lib/createCollection/getMethods/findOneAndUpdate.js +0 -29
- package/lib/createCollection/getMethods/findOneAndUpdate.test.d.ts +0 -1
- package/lib/createCollection/getMethods/findOneAndUpdate.test.js +0 -15
- package/lib/createCollection/getMethods/getSelector.d.ts +0 -3
- package/lib/createCollection/getMethods/getSelector.js +0 -21
- package/lib/createCollection/getMethods/getSelector.test.d.ts +0 -1
- package/lib/createCollection/getMethods/getSelector.test.js +0 -46
- package/lib/createCollection/getMethods/index.d.ts +0 -16
- package/lib/createCollection/getMethods/index.js +0 -36
- package/lib/createCollection/getMethods/insertAndFind.d.ts +0 -3
- package/lib/createCollection/getMethods/insertAndFind.js +0 -31
- package/lib/createCollection/getMethods/insertAndFind.test.d.ts +0 -1
- package/lib/createCollection/getMethods/insertAndFind.test.js +0 -50
- package/lib/createCollection/getMethods/insertMany.d.ts +0 -3
- package/lib/createCollection/getMethods/insertMany.js +0 -36
- package/lib/createCollection/getMethods/insertMany.test.d.ts +0 -1
- package/lib/createCollection/getMethods/insertMany.test.js +0 -66
- package/lib/createCollection/getMethods/insertOne.d.ts +0 -3
- package/lib/createCollection/getMethods/insertOne.js +0 -31
- package/lib/createCollection/getMethods/insertOne.test.d.ts +0 -1
- package/lib/createCollection/getMethods/insertOne.test.js +0 -104
- package/lib/createCollection/getMethods/update.test.d.ts +0 -1
- package/lib/createCollection/getMethods/update.test.js +0 -287
- package/lib/createCollection/getMethods/updateAndFind.d.ts +0 -3
- package/lib/createCollection/getMethods/updateAndFind.js +0 -18
- package/lib/createCollection/getMethods/updateAndFind.test.d.ts +0 -1
- package/lib/createCollection/getMethods/updateAndFind.test.js +0 -38
- package/lib/createCollection/getMethods/updateItem.d.ts +0 -2
- package/lib/createCollection/getMethods/updateItem.js +0 -19
- package/lib/createCollection/getMethods/updateItem.test.d.ts +0 -1
- package/lib/createCollection/getMethods/updateItem.test.js +0 -38
- package/lib/createCollection/getMethods/updateMany.d.ts +0 -3
- package/lib/createCollection/getMethods/updateMany.js +0 -30
- package/lib/createCollection/getMethods/updateOne.d.ts +0 -3
- package/lib/createCollection/getMethods/updateOne.js +0 -30
- package/lib/createCollection/getMethods/upsert.d.ts +0 -3
- package/lib/createCollection/getMethods/upsert.js +0 -31
- package/lib/createCollection/getMethods/upsert.test.d.ts +0 -1
- package/lib/createCollection/getMethods/upsert.test.js +0 -92
- package/lib/createCollection/getMethods/validateModifier/index.d.ts +0 -1
- package/lib/createCollection/getMethods/validateModifier/index.js +0 -18
- package/lib/createCollection/getMethods/validateModifier/index.test.d.ts +0 -1
- package/lib/createCollection/getMethods/validateModifier/index.test.js +0 -74
- package/lib/createCollection/getMethods/validateModifier/validateInc.d.ts +0 -7
- package/lib/createCollection/getMethods/validateModifier/validateInc.js +0 -20
- package/lib/createCollection/getMethods/validateModifier/validateInc.test.d.ts +0 -1
- package/lib/createCollection/getMethods/validateModifier/validateInc.test.js +0 -12
- package/lib/createCollection/getMethods/validateModifier/validateOperator.d.ts +0 -5
- package/lib/createCollection/getMethods/validateModifier/validateOperator.js +0 -34
- package/lib/createCollection/getMethods/validateModifier/validatePush.d.ts +0 -8
- package/lib/createCollection/getMethods/validateModifier/validatePush.js +0 -27
- package/lib/createCollection/getMethods/validateModifier/validatePush.test.d.ts +0 -1
- package/lib/createCollection/getMethods/validateModifier/validatePush.test.js +0 -90
- package/lib/createCollection/getMethods/validateModifier/validateSet.d.ts +0 -7
- package/lib/createCollection/getMethods/validateModifier/validateSet.js +0 -19
- package/lib/createCollection/getMethods/validateModifier/validateSet.test.d.ts +0 -1
- package/lib/createCollection/getMethods/validateModifier/validateSet.test.js +0 -16
- package/lib/createCollection/getMethods/validateModifier/validateUnset.d.ts +0 -7
- package/lib/createCollection/getMethods/validateModifier/validateUnset.js +0 -19
- package/lib/createCollection/getMethods/validateModifier/validateUnset.test.d.ts +0 -1
- package/lib/createCollection/getMethods/validateModifier/validateUnset.test.js +0 -71
- package/lib/createCollection/getMethods/validateModifier/validateUpsert.d.ts +0 -1
- package/lib/createCollection/getMethods/validateModifier/validateUpsert.js +0 -43
- package/lib/createCollection/getMethods/validateModifier/validateUpsert.test.d.ts +0 -1
- package/lib/createCollection/getMethods/validateModifier/validateUpsert.test.js +0 -50
- package/lib/createCollection/getMethods/wrapErrors.d.ts +0 -1
- package/lib/createCollection/getMethods/wrapErrors.js +0 -29
- package/lib/createCollection/getSchemaAndModel.d.ts +0 -10
- package/lib/createCollection/getSchemaAndModel.js +0 -41
- package/lib/createCollection/handleError.d.ts +0 -1
- package/lib/createCollection/handleError.js +0 -25
- package/lib/createCollection/index.d.ts +0 -4
- package/lib/createCollection/index.js +0 -77
- package/lib/createCollection/initItem.d.ts +0 -2
- package/lib/createCollection/initItem.js +0 -13
- package/lib/createCollection/typedModel.test.d.ts +0 -1
- package/lib/createCollection/typedModel.test.js +0 -159
- package/lib/helpers/fromDot.d.ts +0 -1
- package/lib/helpers/fromDot.js +0 -12
- package/lib/helpers/fromDot.test.d.ts +0 -1
- package/lib/helpers/fromDot.test.js +0 -47
- package/lib/helpers/toDot.d.ts +0 -1
- package/lib/helpers/toDot.js +0 -11
- package/lib/helpers/toDot.test.d.ts +0 -1
- package/lib/helpers/toDot.test.js +0 -23
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -35
- package/lib/service/index.d.ts +0 -3
- package/lib/service/index.js +0 -32
- package/lib/service/index.test.d.ts +0 -1
- package/lib/service/index.test.js +0 -73
- package/lib/tests/setup.d.ts +0 -1
- package/lib/tests/setup.js +0 -20
- package/lib/types/index.d.ts +0 -178
- package/lib/types/index.js +0 -2
- package/lib/types/types.test.d.ts +0 -1
- package/lib/types/types.test.js +0 -59
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const insertMany_1 = __importDefault(require("./insertMany"));
|
|
7
|
-
const helpers_1 = require("@orion-js/helpers");
|
|
8
|
-
const __1 = __importDefault(require(".."));
|
|
9
|
-
const models_1 = require("@orion-js/models");
|
|
10
|
-
it('should return a function', async () => {
|
|
11
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)() });
|
|
12
|
-
const insertMany = (0, insertMany_1.default)(Tests);
|
|
13
|
-
expect(typeof insertMany).toBe('function');
|
|
14
|
-
});
|
|
15
|
-
it('insert documents without errors', async () => {
|
|
16
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)() });
|
|
17
|
-
await Tests.insertMany([{ hello: 'world' }, { hello: 'world' }]);
|
|
18
|
-
const count = await Tests.estimatedDocumentCount();
|
|
19
|
-
expect(count).toBe(2);
|
|
20
|
-
});
|
|
21
|
-
it('should throw an error when no document is passed', async () => {
|
|
22
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)() });
|
|
23
|
-
expect.assertions(1);
|
|
24
|
-
try {
|
|
25
|
-
await Tests.insertMany([{ a: 1 }, null]);
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
expect(error.message).toBe('Item at index 1 is not a document');
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
it('should insert documents passing deep validation', async () => {
|
|
32
|
-
const wife = {
|
|
33
|
-
name: { type: String }
|
|
34
|
-
};
|
|
35
|
-
const schema = {
|
|
36
|
-
wife: { type: wife }
|
|
37
|
-
};
|
|
38
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
39
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)(), model });
|
|
40
|
-
await Tests.insertMany([{ 'wife.name': 'Francisca' }]);
|
|
41
|
-
});
|
|
42
|
-
it('should clean a document before inserting', async () => {
|
|
43
|
-
const now = new Date();
|
|
44
|
-
const schema = {
|
|
45
|
-
name: { type: String },
|
|
46
|
-
createdAt: { type: Date, autoValue: () => now }
|
|
47
|
-
};
|
|
48
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
49
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)(), model });
|
|
50
|
-
const [docId] = await Tests.insertMany([{ name: 1234 }]);
|
|
51
|
-
const result = await Tests.findOne(docId);
|
|
52
|
-
expect(result.name).toBe('1234');
|
|
53
|
-
expect(result.createdAt).toEqual(now);
|
|
54
|
-
});
|
|
55
|
-
it('should validate a document', async () => {
|
|
56
|
-
const schema = { name: { type: String } };
|
|
57
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
58
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)(), model });
|
|
59
|
-
expect.assertions(1);
|
|
60
|
-
try {
|
|
61
|
-
await Tests.insertMany([{}]);
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
expect(error.code).toBe('validationError');
|
|
65
|
-
}
|
|
66
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
7
|
-
const fromDot_1 = __importDefault(require("../../helpers/fromDot"));
|
|
8
|
-
const schema_1 = require("@orion-js/schema");
|
|
9
|
-
const wrapErrors_1 = require("./wrapErrors");
|
|
10
|
-
exports.default = (collection) => {
|
|
11
|
-
const insertOne = async (insertDoc, options = {}) => {
|
|
12
|
-
await collection.connectionPromise;
|
|
13
|
-
let doc = insertDoc;
|
|
14
|
-
if (!doc || !(0, isPlainObject_1.default)(doc)) {
|
|
15
|
-
throw new Error('Insert must receive a document');
|
|
16
|
-
}
|
|
17
|
-
if (!doc._id) {
|
|
18
|
-
doc._id = collection.generateId();
|
|
19
|
-
}
|
|
20
|
-
if (collection.schema) {
|
|
21
|
-
const schema = collection.getSchema();
|
|
22
|
-
doc = await (0, schema_1.clean)(schema, (0, fromDot_1.default)(doc));
|
|
23
|
-
await (0, schema_1.validate)(schema, doc);
|
|
24
|
-
}
|
|
25
|
-
await (0, wrapErrors_1.wrapErrors)(async () => {
|
|
26
|
-
await collection.rawCollection.insertOne(doc, options.mongoOptions);
|
|
27
|
-
});
|
|
28
|
-
return doc._id;
|
|
29
|
-
};
|
|
30
|
-
return insertOne;
|
|
31
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const insertOne_1 = __importDefault(require("./insertOne"));
|
|
7
|
-
const helpers_1 = require("@orion-js/helpers");
|
|
8
|
-
const __1 = __importDefault(require(".."));
|
|
9
|
-
const models_1 = require("@orion-js/models");
|
|
10
|
-
describe('InsertOne', () => {
|
|
11
|
-
it('should return a function', async () => {
|
|
12
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)() });
|
|
13
|
-
const insertOne = (0, insertOne_1.default)(Tests);
|
|
14
|
-
expect(typeof insertOne).toBe('function');
|
|
15
|
-
});
|
|
16
|
-
it('insertOnes a document without errors', async () => {
|
|
17
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)() });
|
|
18
|
-
await Tests.insertOne({ hello: 'world' });
|
|
19
|
-
const count = await Tests.estimatedDocumentCount();
|
|
20
|
-
expect(count).toBe(1);
|
|
21
|
-
});
|
|
22
|
-
it('should insertOne documents passing deep validation', async () => {
|
|
23
|
-
const wife = {
|
|
24
|
-
name: { type: String }
|
|
25
|
-
};
|
|
26
|
-
const schema = {
|
|
27
|
-
wife: { type: wife }
|
|
28
|
-
};
|
|
29
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
30
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)(), model });
|
|
31
|
-
await Tests.insertOne({ 'wife.name': 'Francisca' });
|
|
32
|
-
});
|
|
33
|
-
it('should clean a document before insertOneing', async () => {
|
|
34
|
-
const now = new Date();
|
|
35
|
-
const schema = {
|
|
36
|
-
name: { type: String },
|
|
37
|
-
createdAt: { type: Date, autoValue: () => now }
|
|
38
|
-
};
|
|
39
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
40
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)(), model });
|
|
41
|
-
const docId = await Tests.insertOne({ name: 1234 });
|
|
42
|
-
const result = await Tests.findOne(docId);
|
|
43
|
-
expect(result.name).toBe('1234');
|
|
44
|
-
expect(result.createdAt).toEqual(now);
|
|
45
|
-
});
|
|
46
|
-
it('should validate a document', async () => {
|
|
47
|
-
const schema = { name: { type: String } };
|
|
48
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
49
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)(), model });
|
|
50
|
-
expect.assertions(1);
|
|
51
|
-
try {
|
|
52
|
-
await Tests.insertOne({});
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
expect(error.code).toBe('validationError');
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
it('Should be able to use custom clean for models', async () => {
|
|
59
|
-
const model = (0, models_1.createModel)({
|
|
60
|
-
name: 'File',
|
|
61
|
-
schema: {
|
|
62
|
-
name: { type: String }
|
|
63
|
-
},
|
|
64
|
-
async clean(value) {
|
|
65
|
-
if (!value)
|
|
66
|
-
return null;
|
|
67
|
-
return {
|
|
68
|
-
...value,
|
|
69
|
-
name: value.name.toUpperCase() + value._id
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)(), model });
|
|
74
|
-
const docId = await Tests.insertOne({ name: 'hello' });
|
|
75
|
-
const result = await Tests.findOne(docId);
|
|
76
|
-
expect(result.name).toBe('HELLO' + docId);
|
|
77
|
-
});
|
|
78
|
-
it('should throw unique index errors', async () => {
|
|
79
|
-
const Tests = (0, __1.default)({
|
|
80
|
-
name: (0, helpers_1.generateId)(),
|
|
81
|
-
indexes: [
|
|
82
|
-
{
|
|
83
|
-
keys: {
|
|
84
|
-
name: 1
|
|
85
|
-
},
|
|
86
|
-
options: {
|
|
87
|
-
unique: true
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
});
|
|
92
|
-
await Tests.createIndexesPromise;
|
|
93
|
-
await Tests.insertOne({ name: 'one' });
|
|
94
|
-
expect.assertions(3);
|
|
95
|
-
try {
|
|
96
|
-
await Tests.insertOne({ name: 'one' });
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
expect(error.code).toBe('validationError');
|
|
100
|
-
expect(error.validationErrors).toHaveProperty('name');
|
|
101
|
-
expect(error.validationErrors.name).toBe('notUnique');
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const helpers_1 = require("@orion-js/helpers");
|
|
7
|
-
const models_1 = require("@orion-js/models");
|
|
8
|
-
const __1 = __importDefault(require(".."));
|
|
9
|
-
it('updates a document without errors', async () => {
|
|
10
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)() });
|
|
11
|
-
const docId = await Tests.insertOne({ hello: 'world' });
|
|
12
|
-
const result = await Tests.updateOne(docId, { $set: { hello: 'country' } });
|
|
13
|
-
expect(result.modifiedCount).toBe(1);
|
|
14
|
-
const final = await Tests.findOne(docId);
|
|
15
|
-
expect(final.hello).toBe('country');
|
|
16
|
-
});
|
|
17
|
-
it('updates multiple document without errors', async () => {
|
|
18
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)() });
|
|
19
|
-
await Tests.insertOne({ hello: 'world' });
|
|
20
|
-
await Tests.insertOne({ hello: 'world' });
|
|
21
|
-
const result = await Tests.updateMany({}, { $set: { hello: 'country' } });
|
|
22
|
-
expect(result.modifiedCount).toBe(2);
|
|
23
|
-
const items = await Tests.find({}).toArray();
|
|
24
|
-
for (const item of items) {
|
|
25
|
-
expect(item.hello).toBe('country');
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
it('should update documents that have array passing validation', async () => {
|
|
29
|
-
const friend = {
|
|
30
|
-
name: { type: String }
|
|
31
|
-
};
|
|
32
|
-
const schema = {
|
|
33
|
-
friends: { type: [friend] }
|
|
34
|
-
};
|
|
35
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
36
|
-
const Tests = (0, __1.default)({
|
|
37
|
-
name: (0, helpers_1.generateId)(),
|
|
38
|
-
model
|
|
39
|
-
});
|
|
40
|
-
const personId = await Tests.insertOne({ friends: [{ name: 'Roberto' }, { name: 'Joaquín' }] });
|
|
41
|
-
await Tests.updateOne(personId, { $set: { 'friends.0.name': 'Robert' } });
|
|
42
|
-
expect(await Tests.findOne(personId)).toEqual({
|
|
43
|
-
_id: personId,
|
|
44
|
-
friends: [{ name: 'Robert' }, { name: 'Joaquín' }]
|
|
45
|
-
});
|
|
46
|
-
await Tests.updateOne(personId, {
|
|
47
|
-
$push: {
|
|
48
|
-
friends: { name: 'Bastian' }
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
expect(await Tests.findOne(personId)).toEqual({
|
|
52
|
-
_id: personId,
|
|
53
|
-
friends: [{ name: 'Robert' }, { name: 'Joaquín' }, { name: 'Bastian' }]
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
it('should do $pull operation', async () => {
|
|
57
|
-
const schema = {
|
|
58
|
-
tags: { type: [String] }
|
|
59
|
-
};
|
|
60
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
61
|
-
const Tests = (0, __1.default)({
|
|
62
|
-
name: (0, helpers_1.generateId)(),
|
|
63
|
-
model
|
|
64
|
-
});
|
|
65
|
-
const itemId = await Tests.insertOne({ tags: ['1', '2', '3', '4'] });
|
|
66
|
-
await Tests.updateOne(itemId, { $pull: { tags: '1' } });
|
|
67
|
-
await Tests.updateOne(itemId, { $pull: { tags: { $in: ['3', '4'] } } });
|
|
68
|
-
expect(await Tests.findOne(itemId)).toEqual({
|
|
69
|
-
_id: itemId,
|
|
70
|
-
tags: ['2']
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
it('should update documents passing validation', async () => {
|
|
74
|
-
const wife = {
|
|
75
|
-
name: { type: String },
|
|
76
|
-
state: { type: String }
|
|
77
|
-
};
|
|
78
|
-
const schema = {
|
|
79
|
-
wife: { type: wife }
|
|
80
|
-
};
|
|
81
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
82
|
-
const Tests = (0, __1.default)({
|
|
83
|
-
name: (0, helpers_1.generateId)(),
|
|
84
|
-
model
|
|
85
|
-
});
|
|
86
|
-
const personId = await Tests.insertOne({ 'wife.state': 'Hungry', 'wife.name': 'Francisca' });
|
|
87
|
-
await Tests.updateOne(personId, { $set: { 'wife.state': 'Full' } });
|
|
88
|
-
const doc = await Tests.findOne(personId);
|
|
89
|
-
expect(doc).toEqual({ _id: personId, wife: { state: 'Full', name: 'Francisca' } });
|
|
90
|
-
});
|
|
91
|
-
it('should handle $inc operator on blackbox', async () => {
|
|
92
|
-
const schema = {
|
|
93
|
-
services: {
|
|
94
|
-
type: 'blackbox'
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const model = (0, models_1.createModel)({
|
|
98
|
-
name: (0, helpers_1.generateId)(),
|
|
99
|
-
schema
|
|
100
|
-
});
|
|
101
|
-
const Tests = (0, __1.default)({
|
|
102
|
-
name: (0, helpers_1.generateId)(),
|
|
103
|
-
model
|
|
104
|
-
});
|
|
105
|
-
const userId = await Tests.insertOne({ services: { phoneVerification: { tries: 1 } } });
|
|
106
|
-
await Tests.updateOne(userId, { $inc: { 'services.phoneVerification.tries': 1 } });
|
|
107
|
-
const doc = await Tests.findOne(userId);
|
|
108
|
-
expect(doc).toEqual({ _id: userId, services: { phoneVerification: { tries: 2 } } });
|
|
109
|
-
});
|
|
110
|
-
it('should update documents passing validation with blackbox field', async () => {
|
|
111
|
-
const model = (0, models_1.createModel)({
|
|
112
|
-
name: (0, helpers_1.generateId)(),
|
|
113
|
-
schema: {
|
|
114
|
-
services: { type: 'blackbox' }
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
const Tests = (0, __1.default)({
|
|
118
|
-
name: (0, helpers_1.generateId)(),
|
|
119
|
-
model
|
|
120
|
-
});
|
|
121
|
-
const personId = await Tests.insertOne({ services: { password: 123456 } });
|
|
122
|
-
await Tests.updateOne(personId, { $set: { 'services.forgot': 'mypassword' } });
|
|
123
|
-
const doc = await Tests.findOne(personId);
|
|
124
|
-
expect(doc).toEqual({ _id: personId, services: { password: 123456, forgot: 'mypassword' } });
|
|
125
|
-
});
|
|
126
|
-
it('should throw an error when modifier is invalid', async () => {
|
|
127
|
-
const wife = {
|
|
128
|
-
name: { type: String },
|
|
129
|
-
state: { type: String }
|
|
130
|
-
};
|
|
131
|
-
const schema = {
|
|
132
|
-
wife: { type: wife }
|
|
133
|
-
};
|
|
134
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
135
|
-
const Tests = (0, __1.default)({
|
|
136
|
-
name: (0, helpers_1.generateId)(),
|
|
137
|
-
model
|
|
138
|
-
});
|
|
139
|
-
const personId = await Tests.insertOne({ 'wife.state': 'Hungry', 'wife.name': 'Francisca' });
|
|
140
|
-
expect.assertions(1);
|
|
141
|
-
try {
|
|
142
|
-
await Tests.updateOne(personId, { $set: { 'wife.state': 'Full', 'mom.name': 'Paula' } }, { clean: false });
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
expect(error.code).toBe('validationError');
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
it('dont add autovalue when updating', async () => {
|
|
149
|
-
let index = 1;
|
|
150
|
-
const schema = {
|
|
151
|
-
name: {
|
|
152
|
-
type: String
|
|
153
|
-
},
|
|
154
|
-
count: {
|
|
155
|
-
type: Number,
|
|
156
|
-
autoValue(name) {
|
|
157
|
-
return index++;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
162
|
-
const Tests = (0, __1.default)({
|
|
163
|
-
name: (0, helpers_1.generateId)(),
|
|
164
|
-
model
|
|
165
|
-
});
|
|
166
|
-
const personId = await Tests.insertOne({ name: 'Nicolás' });
|
|
167
|
-
await Tests.updateOne(personId, { $set: { name: 'Nicolás López' } });
|
|
168
|
-
const doc = await Tests.findOne(personId);
|
|
169
|
-
expect(doc).toEqual({ _id: personId, name: 'Nicolás López', count: 1 });
|
|
170
|
-
});
|
|
171
|
-
it('should handle $ correctly', async () => {
|
|
172
|
-
const Email = {
|
|
173
|
-
address: { type: String },
|
|
174
|
-
verified: { type: Boolean }
|
|
175
|
-
};
|
|
176
|
-
const schema = {
|
|
177
|
-
emails: { type: [Email] }
|
|
178
|
-
};
|
|
179
|
-
const model = (0, models_1.createModel)({ name: (0, helpers_1.generateId)(), schema });
|
|
180
|
-
const Tests = (0, __1.default)({
|
|
181
|
-
name: (0, helpers_1.generateId)(),
|
|
182
|
-
model
|
|
183
|
-
});
|
|
184
|
-
const userId = await Tests.insertOne({
|
|
185
|
-
emails: [
|
|
186
|
-
{
|
|
187
|
-
address: 'nicolas@orionsoft.io',
|
|
188
|
-
verified: false
|
|
189
|
-
}
|
|
190
|
-
]
|
|
191
|
-
});
|
|
192
|
-
await Tests.updateOne({ _id: userId, 'emails.address': 'nicolas@orionsoft.io' }, {
|
|
193
|
-
$set: { 'emails.$.verified': 'true' }
|
|
194
|
-
});
|
|
195
|
-
expect(await Tests.findOne(userId)).toEqual({
|
|
196
|
-
_id: userId,
|
|
197
|
-
emails: [
|
|
198
|
-
{
|
|
199
|
-
address: 'nicolas@orionsoft.io',
|
|
200
|
-
verified: true
|
|
201
|
-
}
|
|
202
|
-
]
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
it('should pass full doc on clean as well as validate', async () => {
|
|
206
|
-
const item = { _id: '1234', name: 'Nico' };
|
|
207
|
-
const model = (0, models_1.createModel)({
|
|
208
|
-
name: (0, helpers_1.generateId)(),
|
|
209
|
-
schema: {
|
|
210
|
-
name: {
|
|
211
|
-
type: String,
|
|
212
|
-
clean(value, { doc }) {
|
|
213
|
-
expect(doc).toEqual({ name: item.name });
|
|
214
|
-
return value;
|
|
215
|
-
},
|
|
216
|
-
validate(value, { doc }) {
|
|
217
|
-
expect(doc).toEqual({ name: item.name });
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
const Tests = (0, __1.default)({
|
|
223
|
-
name: (0, helpers_1.generateId)(),
|
|
224
|
-
model
|
|
225
|
-
});
|
|
226
|
-
await Tests.updateOne({}, { $set: { name: 'Nico' } });
|
|
227
|
-
});
|
|
228
|
-
it('Should allow custom clean function on a blackbox field', async () => {
|
|
229
|
-
const model = (0, models_1.createModel)({
|
|
230
|
-
name: 'Item',
|
|
231
|
-
schema: {
|
|
232
|
-
info: {
|
|
233
|
-
type: 'blackbox',
|
|
234
|
-
optional: true,
|
|
235
|
-
async clean(info, { doc }) {
|
|
236
|
-
return { hello: 'world' };
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
const Tests = (0, __1.default)({
|
|
242
|
-
name: (0, helpers_1.generateId)(),
|
|
243
|
-
model
|
|
244
|
-
});
|
|
245
|
-
const itemId = await Tests.insertOne({ info: { hello: 'world2' } });
|
|
246
|
-
await Tests.updateOne(itemId, { $set: { info: { hello: 'world444' } } });
|
|
247
|
-
const item = await Tests.findOne(itemId);
|
|
248
|
-
expect(item).toEqual({ _id: itemId, info: { hello: 'world' } });
|
|
249
|
-
});
|
|
250
|
-
it('Should be able to use custom clean for models on update', async () => {
|
|
251
|
-
const modelFile = (0, models_1.createModel)({
|
|
252
|
-
name: 'File',
|
|
253
|
-
schema: {
|
|
254
|
-
name: { type: String },
|
|
255
|
-
lastName: { type: String, optional: true }
|
|
256
|
-
},
|
|
257
|
-
async clean(value) {
|
|
258
|
-
if (!value)
|
|
259
|
-
return null;
|
|
260
|
-
expect(typeof value.name).toBe('string');
|
|
261
|
-
return {
|
|
262
|
-
...value,
|
|
263
|
-
name: value.name.toUpperCase(),
|
|
264
|
-
lastName: '1'
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
const model = (0, models_1.createModel)({
|
|
269
|
-
name: 'Item',
|
|
270
|
-
schema: {
|
|
271
|
-
file: { type: modelFile }
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)(), model });
|
|
275
|
-
const docId = await Tests.insertOne({
|
|
276
|
-
file: { name: '1' }
|
|
277
|
-
});
|
|
278
|
-
await Tests.updateOne(docId, {
|
|
279
|
-
$set: {
|
|
280
|
-
file: { name: 'Hello' }
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
const result = await Tests.findOne(docId);
|
|
284
|
-
expect(result.file.name).toBe('HELLO');
|
|
285
|
-
expect(result.file.lastName).toBe('1');
|
|
286
|
-
expect.assertions(4);
|
|
287
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const wrapErrors_1 = require("./wrapErrors");
|
|
4
|
-
exports.default = (collection) => {
|
|
5
|
-
const updateAndFind = async function (selector, modifier, options = {}) {
|
|
6
|
-
await collection.connectionPromise;
|
|
7
|
-
return await (0, wrapErrors_1.wrapErrors)(async () => {
|
|
8
|
-
return await collection.findOneAndUpdate(selector, modifier, {
|
|
9
|
-
...options,
|
|
10
|
-
mongoOptions: {
|
|
11
|
-
...options.mongoOptions,
|
|
12
|
-
returnDocument: 'after'
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
return updateAndFind;
|
|
18
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const helpers_1 = require("@orion-js/helpers");
|
|
16
|
-
const typed_model_1 = require("@orion-js/typed-model");
|
|
17
|
-
const __1 = __importDefault(require(".."));
|
|
18
|
-
it('update and finds the item and doesnt replaces the variable using updateAndFind', async () => {
|
|
19
|
-
let Item = class Item {
|
|
20
|
-
};
|
|
21
|
-
__decorate([
|
|
22
|
-
(0, typed_model_1.Prop)(),
|
|
23
|
-
__metadata("design:type", String)
|
|
24
|
-
], Item.prototype, "_id", void 0);
|
|
25
|
-
__decorate([
|
|
26
|
-
(0, typed_model_1.Prop)(),
|
|
27
|
-
__metadata("design:type", String)
|
|
28
|
-
], Item.prototype, "text", void 0);
|
|
29
|
-
Item = __decorate([
|
|
30
|
-
(0, typed_model_1.TypedModel)()
|
|
31
|
-
], Item);
|
|
32
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)(), model: Item });
|
|
33
|
-
await Tests.insertOne({ text: 'hello' });
|
|
34
|
-
const oldItem = await Tests.findOne();
|
|
35
|
-
const newItem = await Tests.updateAndFind(oldItem._id, { $set: { text: 'world' } });
|
|
36
|
-
expect(oldItem.text).toBe('hello');
|
|
37
|
-
expect(newItem.text).toBe('world');
|
|
38
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const wrapErrors_1 = require("./wrapErrors");
|
|
4
|
-
function default_1(collection) {
|
|
5
|
-
const updateItem = async function (item, modifier, options = {}) {
|
|
6
|
-
await collection.connectionPromise;
|
|
7
|
-
const updated = await (0, wrapErrors_1.wrapErrors)(async () => {
|
|
8
|
-
return await collection.updateAndFind(item._id, modifier, options);
|
|
9
|
-
});
|
|
10
|
-
for (const key in item) {
|
|
11
|
-
delete item[key];
|
|
12
|
-
}
|
|
13
|
-
for (const key in updated) {
|
|
14
|
-
item[key] = updated[key];
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
return updateItem;
|
|
18
|
-
}
|
|
19
|
-
exports.default = default_1;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const helpers_1 = require("@orion-js/helpers");
|
|
16
|
-
const typed_model_1 = require("@orion-js/typed-model");
|
|
17
|
-
const __1 = __importDefault(require(".."));
|
|
18
|
-
it('updates the item variable using updateItem', async () => {
|
|
19
|
-
let Item = class Item {
|
|
20
|
-
};
|
|
21
|
-
__decorate([
|
|
22
|
-
(0, typed_model_1.Prop)(),
|
|
23
|
-
__metadata("design:type", String)
|
|
24
|
-
], Item.prototype, "_id", void 0);
|
|
25
|
-
__decorate([
|
|
26
|
-
(0, typed_model_1.Prop)(),
|
|
27
|
-
__metadata("design:type", String)
|
|
28
|
-
], Item.prototype, "text", void 0);
|
|
29
|
-
Item = __decorate([
|
|
30
|
-
(0, typed_model_1.TypedSchema)()
|
|
31
|
-
], Item);
|
|
32
|
-
const Tests = (0, __1.default)({ name: (0, helpers_1.generateId)(), model: Item });
|
|
33
|
-
await Tests.insertOne({ text: 'hello' });
|
|
34
|
-
const item = await Tests.findOne();
|
|
35
|
-
expect(item.text).toBe('hello');
|
|
36
|
-
await Tests.updateItem(item, { $set: { text: 'world' } });
|
|
37
|
-
expect(item.text).toBe('world');
|
|
38
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const getSelector_1 = __importDefault(require("./getSelector"));
|
|
7
|
-
const cleanModifier_1 = __importDefault(require("./cleanModifier"));
|
|
8
|
-
const validateModifier_1 = __importDefault(require("./validateModifier"));
|
|
9
|
-
const wrapErrors_1 = require("./wrapErrors");
|
|
10
|
-
exports.default = (collection) => {
|
|
11
|
-
const updateMany = async function (selectorArg, modifierArg, options = {}) {
|
|
12
|
-
await collection.connectionPromise;
|
|
13
|
-
let modifier = modifierArg;
|
|
14
|
-
const selector = (0, getSelector_1.default)(arguments);
|
|
15
|
-
if (!modifier) {
|
|
16
|
-
throw new Error('Modifier is required when making an update');
|
|
17
|
-
}
|
|
18
|
-
if (collection.schema) {
|
|
19
|
-
const schema = collection.getSchema();
|
|
20
|
-
modifier = options.clean !== false ? await (0, cleanModifier_1.default)(schema, modifier) : modifier;
|
|
21
|
-
if (options.validate !== false)
|
|
22
|
-
await (0, validateModifier_1.default)(schema, modifier);
|
|
23
|
-
}
|
|
24
|
-
const result = await (0, wrapErrors_1.wrapErrors)(() => {
|
|
25
|
-
return collection.rawCollection.updateMany(selector, modifier, options.mongoOptions);
|
|
26
|
-
});
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
|
-
return updateMany;
|
|
30
|
-
};
|