npm.io
0.0.6 • Published yesterday

n8n-nodes-db-anub

Licence
MIT
Version
0.0.6
Deps
0
Size
50 kB
Vulns
0
Weekly
0

n8n-nodes-db-anub

npm version License: MIT

An n8n community node for interacting with Cloudflare D1 databases via the D1 Manager Worker API.

Features

  • Full CRUD Operations: Select, Insert, Update, Delete records
  • Advanced Queries: JOINs, WHERE conditions, ORDER BY, GROUP BY, LIMIT/OFFSET
  • Aggregate Functions: Count and Exists operations
  • Raw SQL: Execute custom SQL queries
  • Batch Operations: Execute multiple statements atomically
  • Database Discovery: List all configured D1 database bindings
  • Secure Authentication: API key-based authentication
  • AI-Ready: Usable as a tool in n8n AI workflows

Installation

  1. Go to Settings > Community Nodes
  2. Select Install
  3. Enter n8n-nodes-db-anub
  4. Select Install
Via npm
npm install n8n-nodes-db-anub
Manual Installation
# Clone or download this repository
cd n8n-nodes-db-anub
npm install
npm run build
npm link

# In your n8n custom directory
mkdir -p ~/.n8n/custom
cd ~/.n8n/custom
npm init -y
npm link n8n-nodes-db-anub

Prerequisites

  1. D1 Manager Worker deployed to Cloudflare Workers
  2. API Key configured in your worker
  3. D1 Database bindings configured in your worker

See the D1 Manager Worker API documentation for setup instructions.

Credentials Setup

  1. In n8n, go to Credentials > Add Credential
  2. Search for D1 Manager API
  3. Enter:
    • Base URL: Your worker URL (e.g., https://your-worker.your-subdomain.workers.dev)
    • API Key: Your API key for authentication
  4. Click Save

Operations

Resource: Record

Perform CRUD operations on database tables.

Select

Retrieve records from a table with optional filtering, ordering, and pagination.

Field Type Description
Database Select D1 database binding (dropdown list - auto-populated from your worker)
Table String Target table name
Columns String Comma-separated columns (default: *)
Distinct Boolean Return distinct rows only
Where Conditions JSON WHERE condition tree
Joins JSON Array of JOIN clauses
Order By JSON Array of order clauses
Group By JSON Array of columns to group by
Limit Number Maximum rows to return
Offset Number Rows to skip

Example Where Conditions:

{
  "column": "status",
  "op": "=",
  "value": "active"
}

Nested conditions:

{
  "and": [
    { "column": "status", "op": "=", "value": "active" },
    {
      "or": [
        { "column": "score", "op": ">", "value": 100 },
        { "column": "score", "op": "is null" }
      ]
    }
  ]
}

Example Joins:

[
  { "type": "inner", "table": "orders", "on": "users.id = orders.user_id" }
]

Example Order By:

[
  { "column": "created_at", "dir": "desc" },
  { "column": "name", "dir": "asc" }
]
Insert

Insert one or multiple records into a table.

Field Type Description
Database Select D1 database binding (dropdown list)
Table String Target table name
Data Fields Add column name and value pairs

Data Field:

  • Click "Add Column" to add a new column
  • Enter the column name and its value
  • Add as many columns as needed

Example:

Column Name Value
name Alice
email alice@example.com
active true
Update

Update records in a table.

Field Type Description
Database Select D1 database binding (dropdown list)
Table String Target table name
Data Fields Column values to update (add column/value pairs)
Where Conditions JSON WHERE condition tree
Delete

Delete records from a table.

Field Type Description
Database String D1 database binding name
Table String Target table name
Where Conditions JSON WHERE condition tree
Count

Count records in a table.

Field Type Description
Database Select D1 database binding (dropdown list)
Table String Target table name
Where Conditions JSON WHERE condition tree (optional)
Exists

Check if records exist in a table.

Field Type Description
Database Select D1 database binding (dropdown list)
Table String Target table name
Where Conditions JSON WHERE condition tree
Resource: Raw SQL

Execute custom SQL queries.

Field Type Description
Database Select D1 database binding (dropdown list)
SQL Query String Raw SQL to execute

Example:

CREATE TABLE IF NOT EXISTS users (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name TEXT NOT NULL,
  email TEXT UNIQUE,
  created_at TEXT DEFAULT CURRENT_TIMESTAMP
)
Resource: Batch

Execute multiple statements atomically in a single transaction.

Field Type Description
Database Select D1 database binding (dropdown list)
Statements JSON Array of action objects

Example:

[
  {
    "action": "insert",
    "table": "orders",
    "data": { "user_id": 1, "total": 99.99, "status": "pending" }
  },
  {
    "action": "update",
    "table": "users",
    "data": { "order_count": 5 },
    "where": { "column": "id", "op": "=", "value": 1 }
  }
]
Resource: Database

List all configured D1 database bindings.

Response Format

All responses follow this structure:

Success:

{
  "success": true,
  "data": { ... },
  "meta": {
    "rows_read": 5,
    "rows_written": 0,
    "duration_ms": 12
  }
}

Error:

{
  "success": false,
  "error": {
    "message": "Human-readable description",
    "code": "MACHINE_READABLE_CODE"
  }
}

Supported WHERE Operators

Operator Description
=, !=, <> Equality
<, <=, >, >= Comparison
like, not like Pattern matching
glob SQLite GLOB
in, not in Set membership
between Range
is null, is not null Null checks

Development

# Install dependencies
npm install

# Build the node
npm run build

# Development mode with watch
npm run dev

# Lint code
npm run lint
npm run lint:fix

License

MIT

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Support

If you encounter any issues or have questions, please open an issue on GitHub.

Keywords