@mikro-orm/mariadb 6.2.10-dev.59 → 6.2.10-dev.60

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.
@@ -1,4 +1,4 @@
1
- import { type AnyEntity, type Configuration, type ConnectionType, type EntityDictionary, type LoggingOptions, type NativeInsertUpdateManyOptions, type QueryResult, type Transaction } from '@mikro-orm/core';
1
+ import { type AnyEntity, type Configuration, type ConnectionType, type EntityDictionary, type LoggingOptions, type NativeInsertUpdateManyOptions, type QueryResult, type Transaction, type FilterQuery, type UpsertManyOptions } from '@mikro-orm/core';
2
2
  import { AbstractSqlDriver, type Knex, type SqlEntityManager } from '@mikro-orm/knex';
3
3
  import { MariaDbConnection } from './MariaDbConnection';
4
4
  import { MariaDbPlatform } from './MariaDbPlatform';
@@ -8,5 +8,6 @@ export declare class MariaDbDriver extends AbstractSqlDriver<MariaDbConnection,
8
8
  constructor(config: Configuration);
9
9
  private getAutoIncrementIncrement;
10
10
  nativeInsertMany<T extends object>(entityName: string, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
11
+ nativeUpdateMany<T extends object>(entityName: string, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T> & UpsertManyOptions<T>): Promise<QueryResult<T>>;
11
12
  createQueryBuilder<T extends AnyEntity<T>>(entityName: string, ctx?: Transaction<Knex.Transaction>, preferredConnectionType?: ConnectionType, convertCustomTypes?: boolean, loggerContext?: LoggingOptions, alias?: string, em?: SqlEntityManager): MariaDbQueryBuilder<T, any, any, any>;
12
13
  }
package/MariaDbDriver.js CHANGED
@@ -30,6 +30,27 @@ class MariaDbDriver extends knex_1.AbstractSqlDriver {
30
30
  res.row = res.rows[0];
31
31
  return res;
32
32
  }
33
+ async nativeUpdateMany(entityName, where, data, options = {}) {
34
+ const res = await super.nativeUpdateMany(entityName, where, data, options);
35
+ const pks = this.getPrimaryKeyFields(entityName);
36
+ const ctx = options.ctx;
37
+ const autoIncrementIncrement = await this.getAutoIncrementIncrement(ctx);
38
+ let i = 0;
39
+ const rows = where.map(cond => {
40
+ if (res.insertId != null && core_1.Utils.isEmpty(cond)) {
41
+ return { [pks[0]]: res.insertId + (i++ * autoIncrementIncrement) };
42
+ }
43
+ if (cond[pks[0]] == null) {
44
+ return undefined;
45
+ }
46
+ return { [pks[0]]: cond[pks[0]] };
47
+ });
48
+ if (rows.every(i => i !== undefined)) {
49
+ res.rows = rows;
50
+ }
51
+ res.row = res.rows[0];
52
+ return res;
53
+ }
33
54
  createQueryBuilder(entityName, ctx, preferredConnectionType, convertCustomTypes, loggerContext, alias, em) {
34
55
  // do not compute the connectionType if EM is provided as it will be computed from it in the QB later on
35
56
  const connectionType = em ? preferredConnectionType : this.resolveConnectionType({ ctx, connectionType: preferredConnectionType });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/mariadb",
3
- "version": "6.2.10-dev.59",
3
+ "version": "6.2.10-dev.60",
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.59",
61
+ "@mikro-orm/knex": "6.2.10-dev.60",
62
62
  "mariadb": "3.3.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.59"
68
+ "@mikro-orm/core": "6.2.10-dev.60"
69
69
  }
70
70
  }