Actors
The following actors are available globally.
-
The root entry point for the NyaruDB embedded document database.
NyaruDBis an actor that serialises all file I/O through Swift’s concurrency model. It manages the lifecycle of collections, handles manifest I/O, and coordinates durability across all open collections.Opening a database. Provide a directory URL or filesystem path:
let db = try await NyaruDB(path: "path/to/database")Opening collections. Use
collection(_:of:options:)to open or create a typed collection:let users = try await db.collection("users", of: User.self)Lifecycle. Call
sync()to flush pending index and shard I/O, andclose()to shut down cleanly. Afterclose(), the instance cannot be used again.See moreNote
A singleNyaruDBinstance corresponds to one directory on disk. Opening multiple instances pointing at the same directory is not supported.Declaration
Swift
public actor NyaruDB
View on GitHub
Actors Reference