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

    Function firstResilient

    • Reads the first matching row via key routing, falling back to a global all-shards scan when the routed read misses.

      The routed read stays the fast path. The fallback exists for the window where a primary-key -> shard mapping has not been created yet (a brand-new key, an eventually-consistent KV, or a row written directly to a shard), so a single lookup still resolves without the caller wiring their own fanout.

      Type Parameters

      • T = Record<string, unknown>

        Type of the result record

      Parameters

      • key: string

        Primary key used for routing the fast-path read

      • sql: string

        SQL statement to execute

      • bindings: any[] = []

        Parameter values to bind to the SQL statement

      Returns Promise<T | null>

      The first matching row, or null when neither path finds one

      1.2.4

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