@mikro-orm/mongodb 7.3.0-dev.25 → 7.3.0-dev.27

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.
@@ -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
- this.handleVersionProperty(entityName, row, true);
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 };
@@ -608,8 +609,12 @@ export class MongoDriver extends DatabaseDriver {
608
609
  if (versionProperty.runtimeType === 'Date') {
609
610
  data[versionProperty.name] ??= new Date();
610
611
  }
611
- else {
612
- data[versionProperty.name] ??= update ? { $inc: 1 } : 1;
612
+ else if (!update) {
613
+ data[versionProperty.name] ??= 1;
614
+ }
615
+ else if (data[versionProperty.name] == null) {
616
+ delete data[versionProperty.name];
617
+ data.$inc = { ...data.$inc, [versionProperty.fieldNames[0]]: 1 };
613
618
  }
614
619
  }
615
620
  /** @inheritDoc */
@@ -1,4 +1,4 @@
1
- import { EntityManager, Utils, } from '@mikro-orm/core';
1
+ import { EntityManager, Utils, ValidationError, } from '@mikro-orm/core';
2
2
  /**
3
3
  * @inheritDoc
4
4
  */
@@ -36,7 +36,7 @@ export class MongoEntityManager extends EntityManager {
36
36
  const meta = em.getMetadata().find(entityName);
37
37
  const fields = Utils.asArray(groupBy);
38
38
  if (options.having) {
39
- throw new Error('The `having` option is not supported for MongoDB in `countBy`.');
39
+ throw new ValidationError('The `having` option is not supported for MongoDB in `countBy`.');
40
40
  }
41
41
  await em.tryFlush(entityName, options);
42
42
  const rawWhere = options.where;
package/README.md CHANGED
@@ -201,6 +201,10 @@ You can find example integrations for some popular frameworks in the [`mikro-orm
201
201
 
202
202
  - [Express + SQLite](https://github.com/mikro-orm/express-js-example-app)
203
203
 
204
+ ## Supported Versions
205
+
206
+ New features and bug fixes land in the latest major version. The previous major version keeps receiving fixes for high and critical severity vulnerabilities for 12 months after the next major is released, and reaches end of life after that. See the [security policy](SECURITY.md) for the current status of each version and for how to report a vulnerability.
207
+
204
208
  ## Contributing
205
209
 
206
210
  Contributions, issues and feature requests are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process for submitting pull requests to us.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/mongodb",
3
- "version": "7.3.0-dev.25",
3
+ "version": "7.3.0-dev.27",
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",
@@ -47,13 +47,13 @@
47
47
  "copy": "node ../../scripts/copy.mjs"
48
48
  },
49
49
  "dependencies": {
50
- "mongodb": "7.9.0"
50
+ "mongodb": "7.9.1"
51
51
  },
52
52
  "devDependencies": {
53
- "@mikro-orm/core": "^7.2.11"
53
+ "@mikro-orm/core": "^7.2.13"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.3.0-dev.25"
56
+ "@mikro-orm/core": "7.3.0-dev.27"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"