'Is there a way to flatten the fields returned by embeddedEntities in the parent entity?

If you have models set up as such:

@Entity()
class parentEntity {
  @Column()
  public id; 

  @Column(() => Name, { prefix: false })
  name: Name;
}
export default class Name {
  @Column()
  firstName; 

  @Column() 
  lastName(); 
}

And you run

const test = await manager.findOne(ParentEntity, { id: 'stuffs' }); 
console.log(test); 

You'll get the following result:

ParentEntity {
  id: stuffs, 
  name: {
     firstName: 'hello'
     lastName: 'friends'
  }
}

But I'd like for there to be a way to have the found entity assume this format:

ParentEntity {
  id: stuffs, 
  firstName: 'hello'
  lastName: 'friends'
}

Is there any way to achieve this with typeORM as it currently is? Thanks a ton!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source