@mikro-orm/mongodb 6.6.3 → 6.6.4-dev.1

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.
@@ -354,7 +354,7 @@ class MongoConnection extends core_1.Connection {
354
354
  return meta ? meta.collection : name;
355
355
  }
356
356
  logObject(o) {
357
- if (o.session) {
357
+ if (o?.session) {
358
358
  o = { ...o, session: `[ClientSession]` };
359
359
  }
360
360
  return (0, node_util_1.inspect)(o, { depth: 5, compact: true, breakLength: 300 });
package/MongoDriver.js CHANGED
@@ -171,7 +171,13 @@ class MongoDriver extends core_1.DatabaseDriver {
171
171
  getPlatform() {
172
172
  return this.platform;
173
173
  }
174
- renameFields(entityName, data, dotPaths = false, object) {
174
+ renameFields(entityName, data, dotPaths = false, object, root = true) {
175
+ if (data == null && root) {
176
+ return {};
177
+ }
178
+ if (typeof data !== 'object' || data === null) {
179
+ return data;
180
+ }
175
181
  // copy to new variable to prevent changing the T type or doing as unknown casts
176
182
  const copiedData = Object.assign({}, data); // copy first
177
183
  const meta = this.metadata.find(entityName);
@@ -207,13 +213,12 @@ class MongoDriver extends core_1.DatabaseDriver {
207
213
  throw new Error('Full text search is only supported on the top level of the query object.');
208
214
  }
209
215
  core_1.Utils.keys(copiedData).forEach(k => {
210
- if (core_1.Utils.isGroupOperator(k)) {
211
- /* istanbul ignore else */
216
+ if (core_1.Utils.isOperator(k)) {
212
217
  if (Array.isArray(copiedData[k])) {
213
- copiedData[k] = copiedData[k].map(v => this.renameFields(entityName, v));
218
+ copiedData[k] = copiedData[k].map(v => this.renameFields(entityName, v, dotPaths, object, false));
214
219
  }
215
220
  else {
216
- copiedData[k] = this.renameFields(entityName, copiedData[k]);
221
+ copiedData[k] = this.renameFields(entityName, copiedData[k], dotPaths, object, false);
217
222
  }
218
223
  return;
219
224
  }
@@ -228,10 +233,10 @@ class MongoDriver extends core_1.DatabaseDriver {
228
233
  return;
229
234
  }
230
235
  if (prop.array && Array.isArray(copiedData[prop.name])) {
231
- copiedData[prop.name] = copiedData[prop.name].map((item) => this.renameFields(prop.type, item, dotPaths, true));
236
+ copiedData[prop.name] = copiedData[prop.name].map((item) => this.renameFields(prop.type, item, dotPaths, true, false));
232
237
  }
233
238
  else {
234
- copiedData[prop.name] = this.renameFields(prop.type, copiedData[prop.name], dotPaths, prop.object || object);
239
+ copiedData[prop.name] = this.renameFields(prop.type, copiedData[prop.name], dotPaths, prop.object || object, false);
235
240
  }
236
241
  }
237
242
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/mongodb",
3
- "version": "6.6.3",
3
+ "version": "6.6.4-dev.1",
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",
@@ -65,6 +65,6 @@
65
65
  "@mikro-orm/core": "^6.6.3"
66
66
  },
67
67
  "peerDependencies": {
68
- "@mikro-orm/core": "^6.0.0"
68
+ "@mikro-orm/core": "6.6.4-dev.1"
69
69
  }
70
70
  }