SwiftData

A local database for your app


SwiftSail is built on top of SwiftData framework - a new way to handle local persistence.

The way SwiftData is implemented allows you to easily follow clean architecture principles and add new data models.

There's one exception when it comes to clean architecture - SwiftData models are defined in the domain layer and the mapping between data and domain layer was skipped. The main reason for it is that the domain and data models for SwiftData look exactly the same and the only difference is the @Model annotation for the module. I decided to skip the mapping because it would be redundant. Feel free to implement the mapping if you feel like you need to further separate the context.

SwiftSail uses a generic SwiftDataDataSource which implements methods like

func getAll<T: PersistentModel>(type: T.Type) -> [T]
func create<T: PersistentModel>(type: T.Type, model: T)
func delete<T: PersistentModel>(type: T.Type, model: T)
...

In the upcoming versions of SwiftSail, new data source will be implemented to allow you to connect to any remote API and will also support generated code via OpenAPI standards.