@mikro-orm/mongodb 6.2.10-dev.8 → 6.2.10-dev.80
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/MongoConnection.js +8 -2
- package/MongoDriver.js +15 -3
- package/MongoMikroORM.js +2 -2
- package/index.mjs +1 -0
- package/package.json +3 -3
package/MongoConnection.js
CHANGED
|
@@ -249,8 +249,14 @@ class MongoConnection extends core_1.Connection {
|
|
|
249
249
|
const cond = core_1.Utils.isPlainObject(id) ? id : { _id: id };
|
|
250
250
|
const doc = this.createUpdatePayload(row, upsertOptions);
|
|
251
251
|
if (upsert) {
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
if (core_1.Utils.isEmpty(cond)) {
|
|
253
|
+
query += log(() => `bulk.insert(${this.logObject(row)});\n`);
|
|
254
|
+
bulk.insert(row);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
query += log(() => `bulk.find(${this.logObject(cond)}).upsert().update(${this.logObject(doc)});\n`);
|
|
258
|
+
bulk.find(cond).upsert().update(doc);
|
|
259
|
+
}
|
|
254
260
|
return;
|
|
255
261
|
}
|
|
256
262
|
query += log(() => `bulk.find(${this.logObject(cond)}).update(${this.logObject(doc)});\n`);
|
package/MongoDriver.js
CHANGED
|
@@ -104,7 +104,7 @@ class MongoDriver extends core_1.DatabaseDriver {
|
|
|
104
104
|
const meta = this.metadata.find(entityName);
|
|
105
105
|
/* istanbul ignore next */
|
|
106
106
|
const rename = (field) => meta ? (meta.properties[field]?.fieldNames[0] ?? field) : field;
|
|
107
|
-
if (options.onConflictFields) {
|
|
107
|
+
if (options.onConflictFields && Array.isArray(options.onConflictFields)) {
|
|
108
108
|
options.onConflictFields = options.onConflictFields.map(rename);
|
|
109
109
|
}
|
|
110
110
|
if (options.onConflictMergeFields) {
|
|
@@ -127,7 +127,7 @@ class MongoDriver extends core_1.DatabaseDriver {
|
|
|
127
127
|
const meta = this.metadata.find(entityName);
|
|
128
128
|
/* istanbul ignore next */
|
|
129
129
|
const rename = (field) => meta ? (meta.properties[field]?.fieldNames[0] ?? field) : field;
|
|
130
|
-
if (options.onConflictFields) {
|
|
130
|
+
if (options.onConflictFields && Array.isArray(options.onConflictFields)) {
|
|
131
131
|
options.onConflictFields = options.onConflictFields.map(rename);
|
|
132
132
|
}
|
|
133
133
|
if (options.onConflictMergeFields) {
|
|
@@ -136,7 +136,19 @@ class MongoDriver extends core_1.DatabaseDriver {
|
|
|
136
136
|
if (options.onConflictExcludeFields) {
|
|
137
137
|
options.onConflictExcludeFields = options.onConflictExcludeFields.map(rename);
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
/* istanbul ignore next */
|
|
140
|
+
const pk = meta?.getPrimaryProps()[0].fieldNames[0] ?? '_id';
|
|
141
|
+
const res = await this.rethrow(this.getConnection('write').bulkUpdateMany(entityName, where, data, options.ctx, options.upsert, options));
|
|
142
|
+
if (res.insertedIds) {
|
|
143
|
+
let i = 0;
|
|
144
|
+
res.rows = where.map(cond => {
|
|
145
|
+
if (core_1.Utils.isEmpty(cond)) {
|
|
146
|
+
return { [pk]: res.insertedIds[i++] };
|
|
147
|
+
}
|
|
148
|
+
return { [pk]: cond[pk] };
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return res;
|
|
140
152
|
}
|
|
141
153
|
async nativeDelete(entityName, where, options = {}) {
|
|
142
154
|
if (core_1.Utils.isPrimaryKey(where)) {
|
package/MongoMikroORM.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MongoMikroORM = void 0;
|
|
4
|
+
exports.defineMongoConfig = defineMongoConfig;
|
|
4
5
|
const core_1 = require("@mikro-orm/core");
|
|
5
6
|
const MongoDriver_1 = require("./MongoDriver");
|
|
6
7
|
/**
|
|
@@ -26,4 +27,3 @@ exports.MongoMikroORM = MongoMikroORM;
|
|
|
26
27
|
function defineMongoConfig(options) {
|
|
27
28
|
return (0, core_1.defineConfig)({ driver: MongoDriver_1.MongoDriver, ...options });
|
|
28
29
|
}
|
|
29
|
-
exports.defineMongoConfig = defineMongoConfig;
|
package/index.mjs
CHANGED
|
@@ -25,6 +25,7 @@ export const ChangeSet = mod.ChangeSet;
|
|
|
25
25
|
export const ChangeSetComputer = mod.ChangeSetComputer;
|
|
26
26
|
export const ChangeSetPersister = mod.ChangeSetPersister;
|
|
27
27
|
export const ChangeSetType = mod.ChangeSetType;
|
|
28
|
+
export const CharacterType = mod.CharacterType;
|
|
28
29
|
export const Check = mod.Check;
|
|
29
30
|
export const CheckConstraintViolationException = mod.CheckConstraintViolationException;
|
|
30
31
|
export const Collection = mod.Collection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/mongodb",
|
|
3
|
-
"version": "6.2.10-dev.
|
|
3
|
+
"version": "6.2.10-dev.80",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"bson": "^6.7.0",
|
|
62
|
-
"mongodb": "6.
|
|
62
|
+
"mongodb": "6.8.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@mikro-orm/core": "^6.2.9"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@mikro-orm/core": "6.2.10-dev.
|
|
68
|
+
"@mikro-orm/core": "6.2.10-dev.80"
|
|
69
69
|
}
|
|
70
70
|
}
|