AdonisJS automatically returns the base/parent record to the caller from the controller. However, you may have to custom code all of one statement to return a related record after the parent record is committed to the database.
Consider an example -
|
|
When you create a Todo, the controller takes the data sent in the request and commits that to the database. Post commit todo
variable will have the data from database after committing the data.
You have to do a load
and specify entities that need to be refreshed and included in todo
along with the parent record. The newly updated todo
variable with parent and related records will be returned to the caller.