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

    Function collegedb

    • Initializes the configuration and then performs a callback once the configuration has finished initializing.

      Type Parameters

      • T

      Parameters

      • config: CollegeDBConfig

        CollegeDB Configuration

      • callback: () => T

        The callback to perform after the initialization

      Returns Promise<T>

      The result of the callback

      import { collegedb, first } from 'collegedb'

      const result = collegedb({
      kv: env.KV,
      shards: {
      'db-primary': env.DB_PRIMARY, // Existing DB with data
      'db-secondary': env.DB_SECONDARY // Another existing DB
      },
      strategy: 'hash'
      }, async () => {
      return await first('user-123', 'SELECT * FROM users WHERE id = ?', ['user-123']);
      });