graphile-worker-orchid
v1.0.0
Published
Use graphile-worker with orchid-orm
Downloads
66
Readme
graphile-worker-orchid
Use graphile-worker with orchid-orm, including support for transactions.
Install
pnpm add graphile-worker-orchid
Use
Create worker utils:
import { makeWorkerUtils } from "graphile-worker-orchid"
import { orchidORM } from "orchid-orm"
const db = orchidORM({ databaseURL: "..." }, {
// table definitions
})
const { addJob } = makeWorkerUtils(db)
Then call it with job name, params (and possibly options):
await addJob("test", { foo: 123 }, {
jobKey: "testing",
})
This also works in transaction:
await db.$transaction(async () => {
const user = await db.user.select("id", "name", "email").create(userInput)
await addJob("sendRegistrationEmail", { user })
})