@earth-app/collegedb
    Preparing search index...

    Function queryFirst

    • Reads the first matching row, taking the routing key from the statement.

      Type Parameters

      • T = Record<string, unknown>

        Type of the result record

      Parameters

      • sql: string

        Statement text using ? placeholders

      • bindings: any[] = []

        Positional bindings for the statement

      Returns Promise<T | null>

      The first matching row, or null

      If the routing key cannot be determined and onUnroutable is throw

      1.4.0

      const user = await queryFirst<User>('SELECT * FROM users WHERE id = ?', ['user-1']);