Skip to main content
BoutiqueDB is built specifically for modern Swift and SwiftUI. It combines @MainActor thread safety with @LiveQuery property wrappers to deliver effortless reactive state updates.

Observing Database State in SwiftUI

BoutiqueDB provides two dedicated property wrappers for observing queries in real time:
  • @LiveQuery: Observes an array of models matching a StructuredQueries expression.
  • @LiveQueryOne: Observes a single optional model matching a unique query (e.g. by Primary Key).

@LiveQuery Example

TaskListView.swift

@LiveQueryOne Example

TaskDetailView.swift

Dynamic Query Parameterization

If your query depends on user selection or view parameters, initialize @LiveQuery inside your custom initializer:

Xcode Previews Setup

BoutiqueDB includes an in-memory database helper (BoutiqueDB.inMemoryURL()) designed specifically for Xcode Previews and Unit Tests.
ContentView_Previews.swift
Performance Best Practice: Keep @LiveQuery definitions scoped to the specific views that require them. Because BoutiqueDB CDC tracks changes per table, views only re-render when relevant tables undergo mutation!