Tide · Triggers and selection

Batch (mode: 'batch')

mode: 'batch' creates one task, however many rows the selection returns. Its templates read all rows at once as $.rows, and it requires no unitKey.

Reflex
{
  id: 'door.list',
  intent: 'At 18:00, mail the door who is coming tonight.',
  on: {
    clock: { every: 'day', at: '18:00', tz: 'Europe/Vienna' },
  },
  select: {
    query: {
      table: 'bookings',
      night: { $ref: '$.occurrence.key' },
    },
    mode: 'batch',
  },
  effect: {
    name: 'mail.send',
    input: {
      to: 'the door',
      guests: { $pluck: { over: { $ref: '$.rows' }, key: 'member' } },
      seats: {
        $sum: {
          over: { $pluck: { over: { $ref: '$.rows' }, key: 'seats' } },
        },
      },
    },
  },
}
Selected rows
[
  { id: 'B-2040', member: 'ada', seats: 1 },
  { id: 'B-2041', member: 'grace', seats: 2 },
  { id: 'B-2042', member: 'linus', seats: 4 },
]
Task count and mail sent
{
  tasks: 1,
  mailed: [
    {
      to: 'the door',
      guests: ['ada', 'grace', 'linus'],
      seats: 7,
    },
  ],
}
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.