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

    Function insertReturning

    • Inserts a row, then reads it back and returns it.

      Folds the ubiquitous "insert then immediately SELECT the row" pattern into a single call. The row is re-read on the same shard using the routing key, matched by idColumn (defaulting to the value at values[idColumn], else key).

      Type Parameters

      • T = Record<string, unknown>

        Type of the returned row

      Parameters

      • key: string

        Primary key used for shard routing and re-read

      • table: string

        Target table name

      • values: ColumnValues

        Column to value map for the new row

      • options: BuildInsertOptions & { idColumn?: string } = {}

        Insert modifiers plus the idColumn used to re-read (default id)

      Returns Promise<T | null>

      The created row, or null if it could not be read back

      1.2.4

      const created = await insertReturning('user-123', 'users', { id: 'user-123', username: 'ada' });