Fields of relation populated via em.populate
are not included in serialization
#6658
Replies: 2 comments 2 replies
-
Hmm, I thought this was the correct behaviour, but apparently it should work this way, there is some issue with the serialization. I'll try to look into this later today, one workaround I can give you is the explicit serialization. https://mikro-orm.io/docs/serializing#explicit-serialization The other is using const users = await orm.em.find(User, {}, {
populate: ['shop.orders'],
populateWhere: {
shop: {
orders: {
category: 'A',
},
},
},
populateOrderBy: {
shop: {
orders: {
time: QueryOrder.DESC,
},
},
},
}); |
Beta Was this translation helpful? Give feedback.
-
dbf8f3c will help. The main issue was you had two serialization hints for the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
I want to ultimately use
em.populate
to populate the collection for each of the objects retrieved viaem.find
in order to have filtered and ordered collection data. While I am able to achieve it and manipulate them within the cycle, the fields of the collections are not serialized if I try to use thewrap(...).toObject()
.Reproduction
https://github.com/lamkashingpaul/reproduction/tree/3f521fd
What driver are you using?
@mikro-orm/sqlite
MikroORM version
6.4.16-dev.2
Node.js version
v22.14.0
Operating system
Windows
Validations
Beta Was this translation helpful? Give feedback.
All reactions