@mikro-orm/mongodb 7.2.2-dev.9 → 7.2.3-dev.0
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/MongoDriver.js +21 -0
- package/package.json +3 -3
package/MongoDriver.js
CHANGED
|
@@ -422,6 +422,21 @@ export class MongoDriver extends DatabaseDriver {
|
|
|
422
422
|
else if (value == null) {
|
|
423
423
|
prop.fieldNames.forEach(f => (copiedData[f] = null));
|
|
424
424
|
}
|
|
425
|
+
else if (k === prop.fieldNames[1] &&
|
|
426
|
+
Utils.isPlainObject(value) &&
|
|
427
|
+
Object.keys(value).every(o => Utils.isOperator(o))) {
|
|
428
|
+
// the FK field is named after the property, e.g. `{ likeable: { $in: ids } }` when loading the inverse side
|
|
429
|
+
copiedData[k] = this.convertObjectIds(value);
|
|
430
|
+
}
|
|
431
|
+
else if (Utils.isPlainObject(value) &&
|
|
432
|
+
Utils.getObjectKeysSize(value) === 1 &&
|
|
433
|
+
prop.targetMeta.primaryKeys[0] in value) {
|
|
434
|
+
// PK-only condition, e.g. `{ likeable: { _id: { $in: ids } } }`, compares the FK field
|
|
435
|
+
copiedData[prop.fieldNames[1]] = this.convertObjectIds(value[prop.targetMeta.primaryKeys[0]]);
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
throw new Error(`Unsupported condition on polymorphic relation ${meta.className}.${prop.name}, use an entity reference or \`null\` instead.`);
|
|
439
|
+
}
|
|
425
440
|
return;
|
|
426
441
|
}
|
|
427
442
|
else {
|
|
@@ -497,6 +512,12 @@ export class MongoDriver extends DatabaseDriver {
|
|
|
497
512
|
}
|
|
498
513
|
}
|
|
499
514
|
ret.unshift(...meta.primaryKeys.filter(pk => !fields.includes(pk)));
|
|
515
|
+
// `targetKey` values identify the entity like its PK, references resolve it by them
|
|
516
|
+
for (const key of meta.root.targetKeys ?? []) {
|
|
517
|
+
if (meta.properties[key] && !fields.includes(key)) {
|
|
518
|
+
ret.push(meta.properties[key].fieldNames[0]);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
500
521
|
}
|
|
501
522
|
else if (!Utils.isEmpty(exclude) || lazyProps.some(p => !p.formula)) {
|
|
502
523
|
const props = meta.props.filter(prop => this.platform.shouldHaveColumn(prop, populate, exclude));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/mongodb",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.3-dev.0",
|
|
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",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"mongodb": "7.6.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@mikro-orm/core": "^7.2.
|
|
53
|
+
"@mikro-orm/core": "^7.2.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.
|
|
56
|
+
"@mikro-orm/core": "7.2.3-dev.0"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|