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

    Function insertShard

    • Executes an insert directly on a named shard and returns the generated primary key.

      Use this helper when you already know the shard you want to target. The helper still captures the generated id and stores the mapping so routed reads can find the new row later.

      Type Parameters

      • T = Record<string, unknown>

        Type of returned rows when the insert uses RETURNING

      Parameters

      • shardBinding: string

        The shard binding to execute the insert on

      • sql: string

        The INSERT statement to execute

      • bindings: any[] = []

        Parameter values to bind to the statement

      Returns Promise<InsertResult<T>>

      Promise resolving to the write result plus the generated id

      If the insert succeeds but no generated id can be determined

      1.1.4

      const created = await insertShard('db-east',
      'INSERT INTO auto_users (name, email, created_at) VALUES (?, ?, ?)',
      ['Ada', 'ada@example.com', Date.now()]
      );

      console.log(created.generatedId);
      const created = await insertShard('db-east',
      'INSERT INTO auto_users (name, email) VALUES (?, ?) RETURNING id',
      ['Ada', 'ada@example.com']
      );