Explicit options.type is mapped to a single adapter priority.
Otherwise we auto-detect environment:
Browser: ['indexeddb', 'sqljs']: the database is kept in IndexedDB,
with in-memory sql.js where IndexedDB cannot open. file: ':memory:'
(createMemoryDatabase()) keeps ['sqljs'], in memory.
A Capacitor app on a phone: ['capacitor', 'indexeddb', 'sqljs'], as
the resolver chooses.
Deno: ['sqljs']
Node.js with a postgres:// or postgresql:// URL, or Postgres
options that name a server: ['postgres']. There is no fallback to
SQLite: data meant for Postgres would land in a local file. A URL of
another scheme names no server. DATABASE_URL in the environment does
not count here.
With strict on Node, a url or postgres option that names no server
throws instead of choosing the local default (unless file is given), and a
postgres candidate that fails ends resolution.
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.
Create (or auto-resolve) the most appropriate database adapter for the current runtime environment. Priority selection logic:
options.priority(caller-specified) wins entirely.options.typeis mapped to a single adapter priority.file: ':memory:'(createMemoryDatabase()) keeps ['sqljs'], in memory.postgres://orpostgresql://URL, or Postgres options that name a server: ['postgres']. There is no fallback to SQLite: data meant for Postgres would land in a local file. A URL of another scheme names no server. DATABASE_URL in the environment does not count here.With
stricton Node, aurlorpostgresoption that names no server throws instead of choosing the local default (unlessfileis given), and a postgres candidate that fails ends resolution.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.