populate Record's relations returned from async methods #525
Labels
enhancement
mapper relations
Mapper relations are the ability to define a relationship one Mapper has with another Mapper
Description
When using JSData server-side, it is common to immediately return the result from an async op, ie:
The problem with the above code is that the relation field,
posts
will not be populated due to the Mapper'stoJSON
method not being invoked on each record instance with the options{ with: ['posts'] }
.This is a hassle when you are required to write server-side controller methods like this:
Proposal
Adding an option
populateRelations
to theContainer
class that defaults to true would make sense considering aContainer
class is typically used in a server-side environment. When the flag istrue
any async methods invoked with relationswith: [...]
option will be populated on theRecord
object automatically so that common methods will capture the relation fields, ie:JSON.stringify(records)
orconsole.log(records)
.Environment
The text was updated successfully, but these errors were encountered: