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

    Function all

    • Retrieves all records matching the query for a given primary key.

      This function is useful for fetching multiple records based on a primary key. It automatically routes the query to the correct shard based on the provided primary key, ensuring consistent data access.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      • key: string

        Primary key to route the query

      • sql: string

        The SQL statement to execute

      • bindings: any[] = []

        Parameter values to bind to the SQL statement

      Returns Promise<D1Result<T>>

      Promise that resolves to the result of the update operation

      If update fails or routing fails

      type Post = {
      id: string;
      user_id: string;
      title: string;
      content: string;
      };


      // Get user's posts
      const postsResult = await all<Post>('user-123',
      'SELECT * FROM posts WHERE user_id = ? ORDER BY created_at DESC',
      ['user-123']
      );

      console.log(`User has ${postsResult.meta.count} posts`);