@mikro-orm/mongodb 7.2.13-dev.1 → 7.2.13-dev.10
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 +0 -9
- package/MongoDriver.js +9 -4
- package/package.json +2 -2
package/MongoConnection.js
CHANGED
|
@@ -392,17 +392,11 @@ export class MongoConnection extends Connection {
|
|
|
392
392
|
}
|
|
393
393
|
});
|
|
394
394
|
const $unset = {};
|
|
395
|
-
const $inc = {};
|
|
396
395
|
for (const k of Utils.keys(row)) {
|
|
397
396
|
const item = row[k];
|
|
398
397
|
if (typeof item === 'undefined') {
|
|
399
398
|
$unset[k] = '';
|
|
400
399
|
delete row[k];
|
|
401
|
-
continue;
|
|
402
|
-
}
|
|
403
|
-
if (Utils.isPlainObject(item) && '$inc' in item) {
|
|
404
|
-
$inc[k] = item.$inc;
|
|
405
|
-
delete row[k];
|
|
406
400
|
}
|
|
407
401
|
}
|
|
408
402
|
if (upsertOptions) {
|
|
@@ -431,9 +425,6 @@ export class MongoConnection extends Connection {
|
|
|
431
425
|
if (Utils.hasObjectKeys($unset)) {
|
|
432
426
|
doc.$unset = $unset;
|
|
433
427
|
}
|
|
434
|
-
if (Utils.hasObjectKeys($inc)) {
|
|
435
|
-
doc.$inc = $inc;
|
|
436
|
-
}
|
|
437
428
|
if (!Utils.hasObjectKeys(doc.$set)) {
|
|
438
429
|
delete doc.$set;
|
|
439
430
|
}
|
package/MongoDriver.js
CHANGED
|
@@ -282,9 +282,10 @@ export class MongoDriver extends DatabaseDriver {
|
|
|
282
282
|
}
|
|
283
283
|
return row;
|
|
284
284
|
});
|
|
285
|
-
data = data.map(row => {
|
|
285
|
+
data = data.map((row, idx) => {
|
|
286
286
|
row = { ...row };
|
|
287
|
-
|
|
287
|
+
// a row with an empty filter gets inserted, see `nativeUpdate`
|
|
288
|
+
this.handleVersionProperty(entityName, row, !(options.upsert && Utils.isEmpty(where[idx])));
|
|
288
289
|
return this.renameFields(entityName, row);
|
|
289
290
|
});
|
|
290
291
|
options = { ...options };
|
|
@@ -585,8 +586,12 @@ export class MongoDriver extends DatabaseDriver {
|
|
|
585
586
|
if (versionProperty.runtimeType === 'Date') {
|
|
586
587
|
data[versionProperty.name] ??= new Date();
|
|
587
588
|
}
|
|
588
|
-
else {
|
|
589
|
-
data[versionProperty.name] ??=
|
|
589
|
+
else if (!update) {
|
|
590
|
+
data[versionProperty.name] ??= 1;
|
|
591
|
+
}
|
|
592
|
+
else if (data[versionProperty.name] == null) {
|
|
593
|
+
delete data[versionProperty.name];
|
|
594
|
+
data.$inc = { ...data.$inc, [versionProperty.fieldNames[0]]: 1 };
|
|
590
595
|
}
|
|
591
596
|
}
|
|
592
597
|
/** @inheritDoc */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/mongodb",
|
|
3
|
-
"version": "7.2.13-dev.
|
|
3
|
+
"version": "7.2.13-dev.10",
|
|
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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mikro-orm/core": "^7.2.12"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.13-dev.
|
|
56
|
+
"@mikro-orm/core": "7.2.13-dev.10"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|