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
/entity
keys are always added and define theroute scope
- On a
persist
operation kind, eithercreate
orupdate
, thevalidationErrors
key will be added and defaults to an empty array. - On a
read
operation kind, eitherlist
ordetails
, thetotalItems
/retrievedItems
keys will be added and defaults to empty arrays. - The
error
key 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 }
.