@mikro-orm/mysql 6.2.10-dev.7 → 6.2.10-dev.71

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/MySqlDriver.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import type { Configuration, EntityDictionary, NativeInsertUpdateManyOptions, QueryResult } from '@mikro-orm/core';
1
+ import { type Configuration, type EntityDictionary, type FilterQuery, type NativeInsertUpdateManyOptions, type QueryResult, type UpsertManyOptions } from '@mikro-orm/core';
2
2
  import { AbstractSqlDriver, MySqlConnection, MySqlPlatform } from '@mikro-orm/knex';
3
3
  export declare class MySqlDriver extends AbstractSqlDriver<MySqlConnection, MySqlPlatform> {
4
4
  protected autoIncrementIncrement?: number;
5
5
  constructor(config: Configuration);
6
6
  private getAutoIncrementIncrement;
7
7
  nativeInsertMany<T extends object>(entityName: string, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
8
+ nativeUpdateMany<T extends object>(entityName: string, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T> & UpsertManyOptions<T>): Promise<QueryResult<T>>;
8
9
  }
package/MySqlDriver.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MySqlDriver = void 0;
4
+ const core_1 = require("@mikro-orm/core");
4
5
  const knex_1 = require("@mikro-orm/knex");
5
6
  class MySqlDriver extends knex_1.AbstractSqlDriver {
6
7
  autoIncrementIncrement;
@@ -26,5 +27,26 @@ class MySqlDriver extends knex_1.AbstractSqlDriver {
26
27
  res.row = res.rows[0];
27
28
  return res;
28
29
  }
30
+ async nativeUpdateMany(entityName, where, data, options = {}) {
31
+ const res = await super.nativeUpdateMany(entityName, where, data, options);
32
+ const pks = this.getPrimaryKeyFields(entityName);
33
+ const ctx = options.ctx;
34
+ const autoIncrementIncrement = await this.getAutoIncrementIncrement(ctx);
35
+ let i = 0;
36
+ const rows = where.map(cond => {
37
+ if (res.insertId != null && core_1.Utils.isEmpty(cond)) {
38
+ return { [pks[0]]: res.insertId + (i++ * autoIncrementIncrement) };
39
+ }
40
+ if (cond[pks[0]] == null) {
41
+ return undefined;
42
+ }
43
+ return { [pks[0]]: cond[pks[0]] };
44
+ });
45
+ if (rows.every(i => i !== undefined)) {
46
+ res.rows = rows;
47
+ }
48
+ res.row = res.rows[0];
49
+ return res;
50
+ }
29
51
  }
30
52
  exports.MySqlDriver = MySqlDriver;
package/MySqlMikroORM.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineMySqlConfig = exports.MySqlMikroORM = void 0;
3
+ exports.MySqlMikroORM = void 0;
4
+ exports.defineMySqlConfig = defineMySqlConfig;
4
5
  const core_1 = require("@mikro-orm/core");
5
6
  const MySqlDriver_1 = require("./MySqlDriver");
6
7
  /**
@@ -26,4 +27,3 @@ exports.MySqlMikroORM = MySqlMikroORM;
26
27
  function defineMySqlConfig(options) {
27
28
  return (0, core_1.defineConfig)({ driver: MySqlDriver_1.MySqlDriver, ...options });
28
29
  }
29
- exports.defineMySqlConfig = defineMySqlConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/mysql",
3
- "version": "6.2.10-dev.7",
3
+ "version": "6.2.10-dev.71",
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",
@@ -58,13 +58,13 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@mikro-orm/knex": "6.2.10-dev.7",
62
- "mysql2": "3.10.0"
61
+ "@mikro-orm/knex": "6.2.10-dev.71",
62
+ "mysql2": "3.10.1"
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.7"
68
+ "@mikro-orm/core": "6.2.10-dev.71"
69
69
  }
70
70
  }