Skip to main content
BoutiqueDB is organized around a small number of core concepts. Understanding them makes integrating the framework into your iOS or macOS application straightforward.

Database Sandbox File

SQLite-compatible database file residing inside your app container or shared App Group.

Type-Safe Models

Swift structs using @Table and @BoutiqueTable macros with StructuredQueries.

DatabaseActor Concurrency

All engine I/O runs safely off the main thread via @MainActor and background actors.

CDC Live Queries

Automated UI state updates backed by Change Data Capture tokens.

1. The Database File

A BoutiqueDB database is a regular SQLite-compatible file on disk. You select its location using helper methods:
URL
required
Target disk URL. Supported locations include:
  • BoutiqueDB.applicationSupportURL(): Default persistent data sandbox.
  • BoutiqueDB.documentsURL(): User-accessible documents directory.
  • BoutiqueDB.inMemoryURL(): In-memory store for Xcode Previews and tests.
  • App Group Container: Shared database file when multiProcess: true is set.

2. Models (@Table and @BoutiqueTable)

Models are standard Swift structs. StructuredQueries provides @Table for type-safe query generation, while BoutiqueDB provides @BoutiqueTable for Turso-specific table options.
Model Capabilities: @Table exposes Note.all, Note.where { ... }, Note.insert, Note.update, and Codable decoding. @BoutiqueTable adds STRICT, WITHOUT ROWID, and generated columns.

3. Schema Migrations

Migrations in BoutiqueDB are explicit, named, and append-only:

4. Isolation & Concurrency Safety

All database read and write operations are routed through isolation guards:
Actor Isolation: BoutiqueDB itself is annotated with @MainActor so it can be safely owned by SwiftUI views. All heavy disk and engine I/O runs on a dedicated background DatabaseActor.

5. CDC Live Queries

LiveQuery and LiveQueryOne property wrappers subscribe to database change tokens (turso_cdc) and trigger view invalidation automatically:

6. Error Handling

BoutiqueDB surfaces strongly-typed errors via BoutiqueError: