Ducklings API Documentation
    Preparing search index...

    A prepared SQL statement with parameter binding.

    Prepared statements are more secure (prevent SQL injection) and can be more efficient when executing the same query multiple times with different parameters.

    Bind methods are synchronous (store locally), while run() and execute() are async (send to worker).

    const stmt = await conn.prepare('SELECT * FROM users WHERE id = ? AND active = ?');
    stmt.bindInt32(1, userId);
    stmt.bindBoolean(2, true);
    const result = await stmt.run();
    await stmt.close();
    Index

    Constructors

    Methods

    • Execute the prepared statement and return the number of affected rows.

      Use this for INSERT, UPDATE, DELETE statements.

      Returns Promise<number>

      Promise resolving to the number of rows affected

      const stmt = await conn.prepare('DELETE FROM users WHERE id = ?');
      stmt.bindInt32(1, 42);
      const deleted = await stmt.execute();
    • Execute the prepared statement and return results.

      Type Parameters

      • T = Record<string, unknown>

      Returns Promise<T[]>

      Promise resolving to array of result rows as objects

      const stmt = await conn.prepare('SELECT * FROM users WHERE id = ?');
      stmt.bindInt32(1, 42);
      const rows = await stmt.run();