Member Junction
    Preparing search index...

    PostgreSQL implementation of CodeGenConnection. Wraps a pg.Pool and adapts it to the generic interface.

    Parameter handling:

    • SQL Server uses @ParamName for parameter placeholders
    • PostgreSQL uses , , etc. for positional parameters
    • This implementation translates @ParamName references to positional `` parameters
    import pg from 'pg';
    const pool = new pg.Pool({ connectionString: '...', });
    const conn = new PostgreSQLCodeGenConnection(pool);

    // Simple query
    const result = await conn.query("SELECT id, name FROM entities");

    // Parameterized query (uses @-prefix notation, auto-translated to $N)
    const result2 = await conn.queryWithParams(
    "SELECT id FROM entities WHERE name = @Name",
    { Name: 'Users' }
    );

    Implements

    Index

    Constructors

    Accessors

    Methods

    • Executes a SQL query with named parameters. Parameters are passed as key-value pairs and the implementation is responsible for binding them safely (e.g.,

      Parameters

      • sql: string

        The SQL statement with parameter placeholders.

      • params: Record<string, unknown>

        Named parameters as key-value pairs.

      Returns Promise<CodeGenQueryResult>

      The query result with a recordset array.

      for SQL Server, $1/$2 for PostgreSQL).

      For SQL Server, the parameter names in the SQL should use @-prefix notation matching the keys in the params object. For PostgreSQL, the implementation translates @-prefixed names to $N notation.