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

    Function runShard

    • Bypasses the normal routing logic to execute a query directly on a specified shard. This is useful for administrative operations, cross-shard queries, or when you need to query data that doesn't follow the primary key routing pattern.

      Use with caution: This function bypasses routing safeguards and should be used only when you specifically need to target a particular shard.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      • shardBinding: string

        The shard binding name to execute the query on

      • sql: string

        SQL statement to execute

      • bindings: any[] = []

        Parameter values to bind to the SQL statement

      Returns Promise<D1Result<T>>

      Promise resolving to the result of the query execution

      If shard not found or query fails

      // Administrative query: insert a new user directly into a specific shard
      const result = await runShard('db-east',
      'INSERT INTO users (id, name, email) VALUES (?, ?, ?)',
      ['user-789', 'Alice', 'alice@example.com']
      );
      console.log(`Inserted user with ID: ${result.lastInsertId}`);