Replies: 2 comments 15 replies
-
It's all driven by the populate hint of the root entity you serialize, if you call Can you provide some repro so its clear what you are doing? edit: this is the method responsible for updating the serialization context: |
Beta Was this translation helpful? Give feedback.
-
I see. Digging further I think that our issue is only related to serialization, not population. To go into more detail our problem is that we populate a tree where we can have an arbitrary number of branches. Unfortunately I can't share the code, but if I simplify we have an entity like that: class Entity {
@OneToMany(() => Entity, entity => entity.parent)
children = new Collection<Entity>this);
@ManyToOne(() => Entity, { nullable: true })
parent? = Entity;
@Property({ type: 'varchar', length: 100 })
name!: string;
# A bunch of other properties
...
} Before version 6, loading all the entities with a const entities: Entity[] = await this.entitityRepository.findAll({
populate: [
'parent',
'children',
...
]
})
# the interface returns the whole tree
return entities With version 6, it only returns the first level, because of the change on the serialize(). Is there any way to tell the serializer to take everything into account as it was before? |
Beta Was this translation helpful? Give feedback.
-
Hi,
We have a case where we need to use
em.populate()
to load a lot of field on existing entities in some conditions. Following this change (https://mikro-orm.io/docs/upgrading-v5-to-v6#implicit-serialization-changes), it seems that those fields are not serialized by default, and that we should manually do awrap().populated()
for each of them in order to have them in the output (it's a Nest.js project).Shouldn't a call to
em.populate()
automatically add the fields in the serialization? It seems to be a lot of boilerplate to do it manually, when the intent seems quite clear when you populate this way.Thanks!
Simon
Beta Was this translation helpful? Give feedback.
All reactions