timgit / pg-boss

Queueing jobs in Node.js using PostgreSQL like a boss
MIT License
1.73k stars 144 forks source link

how can I update job date? #399

Closed Rana-Almihdhar closed 1 year ago

Rana-Almihdhar commented 1 year ago

Discussed in https://github.com/timgit/pg-boss/discussions/398

Originally posted by **alyatwa** June 9, 2023 if I want to update startAfter date currently I cancel running job and send it again to the queue, is there better way to do this? ```js const jobQuery = `SELECT * FROM "pgboss"."job" WHERE "singletonkey"='onEventEndedQueue-${event.id}';` const result: any = await pgClient.query(jobQuery) if (result.rows.length > 0) { let jobs = result.rows.map((a: JobType) => a.id) await boss.cancel(jobs) } ////////////// await boss.sendAfter( onEventEndedQueue, { eventId: event.id }, { singletonKey: `${onEventEndedQueue}-${event.id}`, }, event.endDate ) ```