-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
Description
Example from the readme:
import { BackendPostgres } from "@openworkflow/backend-postgres";
import { OpenWorkflow } from "openworkflow";
const postgresUrl = process.env.DATABASE_URL; // connection url to your db
const backend = await BackendPostgres.connect(postgresUrl);
const ow = new OpenWorkflow({ backend });
const sendWelcomeEmail = ow.defineWorkflow(
{ name: "send-welcome-email" },
async ({ input, step }) => {
const user = await step.run({ name: "fetch-user" }, async () => {
return await db.users.findOne({ id: input.userId });
});Prefer
import { OpenWorkflow } from "openworkflow";
const ow = new OpenWorkflow(); // uses sqlite backend by default
const sendWelcomeEmail = ow.defineWorkflow(
{ name: "send-welcome-email" },
async ({ input, step }) => {
const user = await step.run({ name: "fetch-user" }, async () => {
return await db.users.findOne({ id: input.userId });
});related: #19 (comment)
This should be kept somewhere as a basic rule, or keep this simply in mind.
Newcomers should not be scared away by complex code or complex documentation.