Tide · Triggers and selectionWrite trigger (
Write trigger (on.fact)
A write trigger (on.fact with an entity) fires a reflex on a write to a table: any write, or only one op. The host reports each write with ingest, and the fact carries the row. A reflex with no select runs for that row, which a template reads as $.row.
{
id: 'booking.cancelled',
intent: 'Confirm a cancellation to the member who cancelled.',
on: { fact: { entity: 'bookings', op: 'delete' } },
effect: {
name: 'mail.send',
input: {
to: { $ref: '$.row.member' },
cancelled: { $ref: '$.row.id' },
},
},
}[
{ op: 'insert', row: { id: 'B-2045', member: 'mia' } },
{ op: 'update', row: { id: 'B-2042', member: 'linus' } },
{ op: 'delete', row: { id: 'B-2039', member: 'ruth' } },
][{ to: 'ruth', cancelled: 'B-2039' }]Runs in this page on the installed package. The input and the expected output are defined by the example.