Events
The resolver generator triggers events when a certain operation is completed.
Below is a list of events that can be hooked into:
afterWrite
#
Unlike middleware, this callback function is called immediately after a write operation was performed (create or update). This is a good time to make any additional writes to your database that the Collaboration system did not make, or perform some special server functionality after a write was performed.
This callback function can be provided to each table entity.
Entity.afterWrite(params): Promise<UpdatedEntity | void>
params
(Object)params.data
(Object) The data that was written to the database.params.knex
(Knex) An instance of Knex that can be used to make additional database queries if needed. This Knex object will already be configured to talk to your database.params.context
(Object) The context of this request. Any data set in your middleware will be available here.params.operation
(string, one ofcreate
orupdate
) The operation that was performed
You can make additional transformations to the data by editing the data
object and returning it. If no data is returned, then no transformations are made. See the examples below for more info.
#
ExamplesMaking additional writes to your database
Transforming data