Skip to content

Commit

Permalink
fix(mongo): fix using custom field name on relations
Browse files Browse the repository at this point in the history
Closes #1279
  • Loading branch information
B4nan committed Jan 7, 2021
1 parent 4924e55 commit 44becca
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/mongodb/src/MongoDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,6 @@ export class MongoDriver extends DatabaseDriver<MongoConnection> {

if (meta?.properties[k]) {
const prop = meta.properties[k];

if (prop.fieldNames) {
Utils.renameKey(data, k, prop.fieldNames[0]);
}

let isObjectId = false;

if (prop.reference === ReferenceType.SCALAR) {
Expand All @@ -228,6 +223,10 @@ export class MongoDriver extends DatabaseDriver<MongoConnection> {
if (isObjectId) {
data[k] = this.convertObjectIds(data[k]);
}

if (prop.fieldNames) {
Utils.renameKey(data, k, prop.fieldNames[0]);
}
}

if (Utils.isPlainObject(data[k]) && '$re' in data[k]) {
Expand Down

0 comments on commit 44becca

Please sign in to comment.