@dypai-ai/client-sdk - v1.12.0
    Preparing search index...

    Class DirectDBModule<TDatabase>

    Direct database access module — bypasses endpoints/workflows. Requires serviceRoleKey (admin-level access).

    WARNING: This is for server-side use only (scripts, migrations, seeds, backend). NEVER expose the serviceRoleKey in browser/client-side code. For end-user data access, use client.db.from() (which goes through endpoints with proper auth).

    // Server-side only (Node.js, Bun, Deno)
    const client = createClient(url, {
    serviceRoleKey: process.env.DYPAI_SERVICE_ROLE_KEY,
    });

    // Bulk import
    await client.db.direct.from('products').insert(csvRows);

    // Migration
    await client.db.direct.sql('ALTER TABLE products ADD COLUMN sku TEXT');

    Type Parameters

    • TDatabase = any

      Optional type map of table names to row types.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Execute raw SQL with positional bind parameters.

      Parameters

      • query: string

        SQL query with $1, $2 placeholders.

      • Optionalparams: any[]

        Values for bind parameters.

      • Optionaloptions: { limit?: number }

        Optional limit for SELECT queries (default: 1000).

      Returns Promise<DypaiResponse<any>>

      const { data } = await client.db.direct.sql(
      'SELECT * FROM products WHERE category = $1 AND price > $2',
      ['electronics', 50]
      );