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

    Function discoverExistingRecordsWithColumns

    • 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

      If table doesn't exist or database query fails

      // Discover all user records with available lookup columns
      const records = await discoverExistingRecordsWithColumns(env.DB_EXISTING, 'users');
      console.log(`Found ${records.length} user records`);
      records.forEach(record => {
      console.log(`ID: ${record.id}, Email: ${record.email || 'N/A'}`);
      });

      1.0.4