UNPKG

513 BJavaScriptView Raw
1const db = require('./db.js');
2
3module.exports = {
4 async schedule({ task, payload = {}, queue = null, runAt = null, maxAttempts = null }) {
5 await db.sql`
6 SELECT * FROM graphile_worker.add_job(
7 identifier => ${task.name}::text,
8 payload => ${payload}::json,
9 queue_name => coalesce(${queue}::text, public.gen_random_uuid()::text),
10 run_at => coalesce(${runAt ? runAt.toISOString() : null}::timestamptz, now()),
11 max_attempts => coalesce(${maxAttempts}::int, 25)
12 );`;
13 }
14};