The D1 database instance to scan
Name of the table to discover primary keys from
Name of the primary key column (defaults to 'id')
Promise resolving to array of primary key values
// Discover all user IDs in an existing users table
const userIds = await discoverExistingPrimaryKeys(env.DB_EXISTING, 'users');
console.log(`Found ${userIds.length} existing users`);
// Discover with custom primary key column
const orderIds = await discoverExistingPrimaryKeys(env.DB_ORDERS, 'orders', 'order_id');
Scans an existing table to find all primary keys that need to be mapped to shards. This is useful when integrating CollegeDB with an existing database that already contains data. The function assumes the table has an 'id' column as the primary key.