Skip to content
Back to skills

444 Step Transactions 0d42104a

ASecurity

Use datasource transactions for database operations within workflows. Transactions commit exactly once and are checkpointed for recovery.

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
databasestypescriptnodedatabase

Works with

  • cli

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 444-step-transactions_0d42104a --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 444 Step Transactions 0d42104a?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 444 Step Transactions 0d42104a
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-444-step-transactions-0d42104a/badge)](https://www.skillsdirectory.com/skills/tools-only-444-step-transactions-0d42104a)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
title: Use Transactions for Database Operations
impact: HIGH
impactDescription: Transactions provide exactly-once database execution within workflows
tags: step, transaction, database, datasource
---

## Use Transactions for Database Operations

Use datasource transactions for database operations within workflows. Transactions commit exactly once and are checkpointed for recovery.

**Incorrect (raw database query in workflow):**

```typescript
import { Pool } from "pg";
const pool = new Pool();

async function myWorkflowFn() {
  // Direct database access in workflow - not checkpointed!
  const result = await pool.query("INSERT INTO orders ...");
}
```

**Correct (using a datasource transaction):**

Install a datasource package (e.g., Knex):
```
npm i @dbos-inc/knex-datasource
```

Configure the datasource:
```typescript
import { KnexDataSource } from "@dbos-inc/knex-datasource";

const config = { client: "pg", connection: process.env.DBOS_DATABASE_URL };
const dataSource = new KnexDataSource("app-db", config);
```

Run transactions inline with `runTransaction`:
```typescript
async function insertOrderFn(userId: string, amount: number) {
  const rows = await dataSource
    .client("orders")
    .insert({ user_id: userId, amount })
    .returning("id");
  return rows[0].id;
}

async function myWorkflowFn(userId: string, amount: number) {
  const orderId = await dataSource.runTransaction(
    () => insertOrderFn(userId, amount),
    { name: "insertOrder" }
  );
  return orderId;
}
const myWorkflow = DBOS.registerWorkflow(myWorkflowFn);
```

You can also pre-register a transaction function with `dataSource.registerTransaction`:
```typescript
const insertOrder = dataSource.registerTransaction(insertOrderFn);
```

Available datasource packages: `@dbos-inc/knex-datasource`, `@dbos-inc/kysely-datasource`, `@dbos-inc/drizzle-datasource`, `@dbos-inc/typeorm-datasource`, `@dbos-inc/prisma-datasource`, `@dbos-inc/nodepg-datasource`, `@dbos-inc/postgres-datasource`.

Datasources require installing the DBOS schema (`transaction_completion` table) via `initializeDBOSSchema`.

Reference: [Transactions & Datasources](https://docs.dbos.dev/typescript/tutorials/transaction-tutorial)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.