@orion-js/mongodb 3.8.0 → 3.9.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.
- package/lib/createCollection/getMethods/insertAndFind.js +2 -2
- package/lib/createCollection/getMethods/insertOne.js +2 -2
- package/lib/createCollection/getMethods/updateItem.js +2 -2
- package/lib/createCollection/getMethods/updateMany.js +1 -1
- package/lib/createCollection/getMethods/updateOne.js +1 -1
- package/lib/createCollection/getMethods/upsert.js +1 -1
- package/lib/types/index.d.ts +1 -1
- package/package.json +10 -10
|
@@ -8,7 +8,7 @@ const fromDot_1 = __importDefault(require("../../helpers/fromDot"));
|
|
|
8
8
|
const schema_1 = require("@orion-js/schema");
|
|
9
9
|
const wrapErrors_1 = require("./wrapErrors");
|
|
10
10
|
exports.default = (collection) => {
|
|
11
|
-
const insertAndFind = async (insertDoc, options) => {
|
|
11
|
+
const insertAndFind = async (insertDoc, options = {}) => {
|
|
12
12
|
await collection.connectionPromise;
|
|
13
13
|
let doc = insertDoc;
|
|
14
14
|
if (!doc || !(0, isPlainObject_1.default)(doc)) {
|
|
@@ -23,7 +23,7 @@ exports.default = (collection) => {
|
|
|
23
23
|
await (0, schema_1.validate)(schema, doc);
|
|
24
24
|
}
|
|
25
25
|
await (0, wrapErrors_1.wrapErrors)(async () => {
|
|
26
|
-
await collection.rawCollection.insertOne(doc);
|
|
26
|
+
await collection.rawCollection.insertOne(doc, options.mongoOptions);
|
|
27
27
|
});
|
|
28
28
|
return doc;
|
|
29
29
|
};
|
|
@@ -8,7 +8,7 @@ const fromDot_1 = __importDefault(require("../../helpers/fromDot"));
|
|
|
8
8
|
const schema_1 = require("@orion-js/schema");
|
|
9
9
|
const wrapErrors_1 = require("./wrapErrors");
|
|
10
10
|
exports.default = (collection) => {
|
|
11
|
-
const insertOne = async (insertDoc, options) => {
|
|
11
|
+
const insertOne = async (insertDoc, options = {}) => {
|
|
12
12
|
await collection.connectionPromise;
|
|
13
13
|
let doc = insertDoc;
|
|
14
14
|
if (!doc || !(0, isPlainObject_1.default)(doc)) {
|
|
@@ -23,7 +23,7 @@ exports.default = (collection) => {
|
|
|
23
23
|
await (0, schema_1.validate)(schema, doc);
|
|
24
24
|
}
|
|
25
25
|
await (0, wrapErrors_1.wrapErrors)(async () => {
|
|
26
|
-
await collection.rawCollection.insertOne(doc);
|
|
26
|
+
await collection.rawCollection.insertOne(doc, options.mongoOptions);
|
|
27
27
|
});
|
|
28
28
|
return doc._id;
|
|
29
29
|
};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const wrapErrors_1 = require("./wrapErrors");
|
|
4
4
|
function default_1(collection) {
|
|
5
|
-
const updateItem = async function (item, modifier) {
|
|
5
|
+
const updateItem = async function (item, modifier, options = {}) {
|
|
6
6
|
await collection.connectionPromise;
|
|
7
7
|
const updated = await (0, wrapErrors_1.wrapErrors)(async () => {
|
|
8
|
-
return await collection.updateAndFind(item._id, modifier);
|
|
8
|
+
return await collection.updateAndFind(item._id, modifier, options);
|
|
9
9
|
});
|
|
10
10
|
for (const key in item) {
|
|
11
11
|
delete item[key];
|
|
@@ -22,7 +22,7 @@ exports.default = (collection) => {
|
|
|
22
22
|
await (0, validateModifier_1.default)(schema, modifier);
|
|
23
23
|
}
|
|
24
24
|
const result = await (0, wrapErrors_1.wrapErrors)(() => {
|
|
25
|
-
return collection.rawCollection.updateMany(selector, modifier);
|
|
25
|
+
return collection.rawCollection.updateMany(selector, modifier, options.mongoOptions);
|
|
26
26
|
});
|
|
27
27
|
return result;
|
|
28
28
|
};
|
|
@@ -22,7 +22,7 @@ exports.default = (collection) => {
|
|
|
22
22
|
await (0, validateModifier_1.default)(schema, modifier);
|
|
23
23
|
}
|
|
24
24
|
const result = await (0, wrapErrors_1.wrapErrors)(() => {
|
|
25
|
-
return collection.rawCollection.updateOne(selector, modifier);
|
|
25
|
+
return collection.rawCollection.updateOne(selector, modifier, options.mongoOptions);
|
|
26
26
|
});
|
|
27
27
|
return result;
|
|
28
28
|
};
|
|
@@ -23,7 +23,7 @@ exports.default = (collection) => {
|
|
|
23
23
|
await (0, validateUpsert_1.default)(schema, selector, modifier);
|
|
24
24
|
}
|
|
25
25
|
const result = await (0, wrapErrors_1.wrapErrors)(() => {
|
|
26
|
-
return collection.rawCollection.updateOne(selector, modifier, { upsert: true });
|
|
26
|
+
return collection.rawCollection.updateOne(selector, modifier, { ...options.mongoOptions, upsert: true });
|
|
27
27
|
});
|
|
28
28
|
return result;
|
|
29
29
|
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ export type FindOne<ModelClass extends ModelClassBase> = (selector?: ModelToMong
|
|
|
80
80
|
export type Find<ModelClass extends ModelClassBase> = (selector?: ModelToMongoSelector<ModelClass>, options?: MongoDB.FindOptions) => FindCursor<ModelClass>;
|
|
81
81
|
export type FindOneAndUpdate<ModelClass extends ModelClassBase> = (selector: ModelToMongoSelector<ModelClass>, modifier: ModelToUpdateFilter<ModelClass>, options?: FindOneAndUpdateUpdateOptions) => Promise<ModelClass>;
|
|
82
82
|
export type UpdateAndFind<ModelClass extends ModelClassBase> = (selector: ModelToMongoSelector<ModelClass>, modifier: ModelToUpdateFilter<ModelClass>, options?: FindOneAndUpdateUpdateOptions) => Promise<ModelClass>;
|
|
83
|
-
export type UpdateItem<ModelClass extends ModelClassBase> = (item: ModelClass, modifier: ModelToUpdateFilter<ModelClass
|
|
83
|
+
export type UpdateItem<ModelClass extends ModelClassBase> = (item: ModelClass, modifier: ModelToUpdateFilter<ModelClass>, options?: FindOneAndUpdateUpdateOptions) => Promise<void>;
|
|
84
84
|
export type InsertOne<ModelClass extends ModelClassBase> = (doc: ModelToDocumentTypeWithIdOptional<ModelClass>, options?: InsertOptions) => Promise<ModelClass['_id']>;
|
|
85
85
|
export type InsertMany<ModelClass extends ModelClassBase> = (doc: Array<ModelToDocumentTypeWithIdOptional<ModelClass>>, options?: InsertOptions) => Promise<Array<ModelClass['_id']>>;
|
|
86
86
|
export type InsertAndFind<ModelClass extends ModelClassBase> = (doc: ModelToDocumentTypeWithIdOptional<ModelClass>, options?: InsertOptions) => Promise<ModelClass>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/mongodb",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.9",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
"upgrade-interactive": "yarn upgrade-interactive"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@orion-js/env": "^3.
|
|
21
|
-
"@orion-js/helpers": "^3.
|
|
22
|
-
"@orion-js/logger": "^3.
|
|
23
|
-
"@orion-js/models": "^3.
|
|
24
|
-
"@orion-js/resolvers": "^3.
|
|
25
|
-
"@orion-js/schema": "^3.
|
|
26
|
-
"@orion-js/services": "^3.
|
|
27
|
-
"@orion-js/typed-model": "^3.
|
|
20
|
+
"@orion-js/env": "^3.9.0",
|
|
21
|
+
"@orion-js/helpers": "^3.9.0",
|
|
22
|
+
"@orion-js/logger": "^3.9.0",
|
|
23
|
+
"@orion-js/models": "^3.9.0",
|
|
24
|
+
"@orion-js/resolvers": "^3.9.0",
|
|
25
|
+
"@orion-js/schema": "^3.9.0",
|
|
26
|
+
"@orion-js/services": "^3.9.0",
|
|
27
|
+
"@orion-js/typed-model": "^3.9.0",
|
|
28
28
|
"bson": "^6.6.0",
|
|
29
29
|
"dataloader": "2.2.2",
|
|
30
30
|
"dot-object": "2.1.4",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "2b8fd41c03f89fc6b075b71380ff42bc814e47d6"
|
|
46
46
|
}
|