Skip to content

Keep Entry Material Super-Simple #46

@laz-001

Description

@laz-001

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions