Introduction#
Each entity-routes response will be formated using a template defined by the route
operation , either list or details. All responses will share the @context part
nonetheless. Here the actual ts type (GenericRouteResponse) :
#ts
@context#
operation/entitykeys are always added and define theroute scope- On a
persistoperation kind, eithercreateorupdate, thevalidationErrorskey will be added and defaults to an empty array. - On a
readoperation kind, eitherlistordetails, thetotalItems/retrievedItemskeys will be added and defaults to empty arrays. - The
errorkey is only added when there is an error, it is populated with the error message caught.
Auto reload#
You can avoid making another request on the entity details route (GET:/xxx/123) to get the latest recorded state
after an entity was persisted using auto-reloading.
On persist operations (create/update), after the entity was successfully saved, it can be auto-reloaded using the
shouldAutoReload key of the CreateUpdateOptions object, passed to the
create/update methods of RouteController.
When an entity is auto-reloaded, it is read from the database using the getDetails method of
RouteController, so that the response is returned the exact same way as if it
was requested through the details route (GET:/xxx/123). The operation used is
either defined explictly by using the responseOperation key of the
CreateUpdateOptions object, or defaults to details elsewise.
By default, it is enabled since the defaultEntityRouteOptions object
has a defaultCreateUpdateOptions key set to { shouldAutoReload: true, shouldFormatResult: true }.