@mikro-orm/core 6.4.4-dev.14 → 6.4.4-dev.15

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.
@@ -40,6 +40,10 @@ export interface AssignOptions<Convert extends boolean> {
40
40
  * to foreign keys. Defaults to `false`.
41
41
  */
42
42
  onlyOwnProperties?: boolean;
43
+ /**
44
+ * With `ignoreUndefined` enabled, `undefined` properties passed in the payload are skipped. Defaults to `false`.
45
+ */
46
+ ignoreUndefined?: boolean;
43
47
  /**
44
48
  * `assign` excepts runtime values for properties using custom types. To be able to assign raw database values, you
45
49
  * can enable the `convertCustomTypes` option. Defaults to `false`.
@@ -37,10 +37,12 @@ class EntityAssigner {
37
37
  return entity;
38
38
  }
39
39
  static assignProperty(entity, propName, props, data, options) {
40
- if (options.onlyProperties && !(propName in props)) {
40
+ let value = data[propName];
41
+ const onlyProperties = options.onlyProperties && !(propName in props);
42
+ const ignoreUndefined = options.ignoreUndefined === true && value === undefined;
43
+ if (onlyProperties || ignoreUndefined) {
41
44
  return;
42
45
  }
43
- let value = data[propName];
44
46
  const prop = { ...props[propName], name: propName };
45
47
  if (prop && options.onlyOwnProperties) {
46
48
  if ([enums_1.ReferenceKind.MANY_TO_MANY, enums_1.ReferenceKind.ONE_TO_MANY].includes(prop.kind)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.4.4-dev.14",
3
+ "version": "6.4.4-dev.15",
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",
@@ -64,7 +64,7 @@
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.3.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.4.4-dev.14",
67
+ "mikro-orm": "6.4.4-dev.15",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -71,6 +71,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
71
71
  updateByPrimaryKey: true;
72
72
  mergeObjectProperties: false;
73
73
  mergeEmbeddedProperties: true;
74
+ ignoreUndefined: false;
74
75
  };
75
76
  persistOnCreate: true;
76
77
  upsertManaged: true;
@@ -65,6 +65,7 @@ class Configuration {
65
65
  updateByPrimaryKey: true,
66
66
  mergeObjectProperties: false,
67
67
  mergeEmbeddedProperties: true,
68
+ ignoreUndefined: false,
68
69
  },
69
70
  persistOnCreate: true,
70
71
  upsertManaged: true,