Discovers existing records with additional columns for multi-key mapping support.
Scans a table to find primary keys along with username, email, and name columns
when they exist, allowing these additional columns to be used as lookup keys.
Parameters
d1: D1Database
The D1 database instance to scan
tableName: string
Name of the table to discover records from
primaryKeyColumn: string = 'id'
Name of the primary key column (defaults to 'id')
Returns Promise<{[key:string]:any}[]>
Promise resolving to array of record data with available columns
Throws
If table doesn't exist or database query fails
Example
// Discover all user records with available lookup columns constrecords = awaitdiscoverExistingRecordsWithColumns(env.DB_EXISTING, 'users'); console.log(`Found ${records.length} user records`); records.forEach(record=> { console.log(`ID: ${record.id}, Email: ${record.email||'N/A'}`); });
Discovers existing records with additional columns for multi-key mapping support. Scans a table to find primary keys along with username, email, and name columns when they exist, allowing these additional columns to be used as lookup keys.