Function createDatabase

  • Create (or auto-resolve) the most appropriate database adapter for the current runtime environment. Priority selection logic:

    1. Explicit options.priority (caller-specified) wins entirely.
    2. Explicit options.type is mapped to a single adapter priority.
    3. Otherwise we auto-detect environment:
      • Browser / Deno: ['sqljs']
      • Node.js: ['better-sqlite3', 'sqljs'] (native first, wasm fallback)

    The function never throws solely due to a native adapter absence; it falls back to next candidates. Only when no candidate can open will it bubble an error.

    Parameters

    Returns Promise<StorageAdapter>