Repository navigation
One shared connection pool, a simpler database API, and reactive queries that no longer hold connections while waiting for changes.
This update brings ordinary queries, model persistence, migrations, transactions, bulk inserts and observations together under one connection management system.
🔌 Automatic connection pooling
Every logical Database now has a single shared connection pool. Instead of opening independent connections for ordinary operations, Duck acquires and returns reusable connections automatically.
By default, each database uses one connection. You can configure the pool before first use:
let database = Database.memory()
try await database.configure(
minimumConnections: 1,
maximumConnections: 4
)The minimum number of connections is opened immediately. Additional connections are opened on demand, up to the configured maximum. Ordinary operations and explicit connections share the same pool.
⚡ Better resource management for reactive queries
The familiar observe(on:) API stays the same, but its connection management has changed.
Each observation borrows a connection only when it needs to refresh its query and returns it after the refresh. Idle observations no longer occupy connections, so multiple live queries can share a small pool.
Transaction changes are coordinated with query refreshes. A commit that happens during an ongoing refresh can trigger another refresh, allowing active observations to catch up with the latest committed state. Intermediate updates may be combined, and unchanged results are not delivered again.
✨ Simpler database identity
Database replaces DatabaseIdentifier, which remains available as a deprecated typealias.
Equivalent database identities share the same runtime, pool and configuration. You can continue using familiar model queries, transactions and persistence APIs without managing connections yourself.
🛠️ Upgrading from 1.0
IMPORTANT: Release tags must now be specified without the v prefix: 1.1.0, not v1.1.0.
Most application code remains unchanged. If you manage connections or pools explicitly, keep these changes in mind:
connect()now acquires a pooled connection. You must awaitrelease()when finished. Prefer scopedconnection { ... }when possible.- While holding a connection, use it for your queries instead of waiting for another connection from an exhausted pool.
- Configure the pool before first use. The deprecated
pool(maximumConnections:)no longer creates a separate pool. pool.shutdown()drains active leases, closes the underlying connections and permanently shuts down that database runtime.
Read the migration guide for more details.
Get started
.package(url: "https://github.com/SwiftStream/Duck", from: "1.1.0")Swift 6.3+ · iOS 15+ · macOS 12+ · Powered by DuckDB 2.0.0