basalt / tenancy-sqlite/src / openTenancyDatabase
Function: openTenancyDatabase()
> openTenancyDatabase(location?): DatabaseSync
Defined in: tenancy-sqlite/src/index.ts:24
Durable, SQLite-backed implementation of the @basaltkit/tenancy TenantSource, on Node's built-in node:sqlite. Zero external dependencies. The single-node reference backend; the production (Postgres/MySQL) counterpart is @basaltkit/tenancy-prisma.
The tenant is an open record ({ id, ...anything }), so it's stored as a JSON blob keyed by id. Custom domains (tenant.domains: string[]) are mirrored into a normalized, indexed tenant_domains table so findByDomain is a keyed lookup rather than a scan.
Requires Node 22.5+ (stable and flag-free on Node 24; --experimental-sqlite on 22.x).
Parameters
location?
string = ':memory:'
Returns
DatabaseSync