Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aaronpearce/Harmony
Harmony provides CloudKit sync for GRDB and only GRDB.
https://github.com/aaronpearce/Harmony
cloudkit grdb
Last synced: 11 days ago
JSON representation
Harmony provides CloudKit sync for GRDB and only GRDB.
- Host: GitHub
- URL: https://github.com/aaronpearce/Harmony
- Owner: aaronpearce
- License: other
- Created: 2023-06-12T07:41:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-24T21:58:05.000Z (8 months ago)
- Last Synced: 2024-05-11T20:16:10.445Z (6 months ago)
- Topics: cloudkit, grdb
- Language: Swift
- Homepage:
- Size: 58.6 KB
- Stars: 104
- Watchers: 6
- Forks: 8
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Harmony
Harmony provides CloudKit sync for GRDB and only GRDB.
**Requirements:** iOS 17.0+, macOS 14.0+, tvOS 17.0+, watchOS 10.0+.
I am open to feedback to style, functionality and other contributions.
## Usage
After installing via Swift Package Manager and enabling CloudKit for your app, add the following to your `App.swift` or equivalent to initialize Harmony.
```
@Harmony(
records: [Model1.self, Model2.self],
configuration: Harmony.Configuration(
cloudKitContainerIdentifier: "xxx" \\ Or leave nil for your default container.
),
migrator: // Your GRDB DatabaseMigrator
) var harmony
```You can then access your Harmony instance from anywhere for writing or reading by simply using:
```
@Harmony var harmony
```Harmony provides access to write methods that will automatically sync to CloudKit and hides direct database writing access for this purpose. If you write via another means to your GRDB database, Harmony will not see those changes.
Harmony also provides direct access to your `DatabaseReader` if you wish to read directly. I highly suggest seeing if GRDBQuery will fit your needs first.
### Foreign Keys
Harmony does not support usage of foreign keys in GRDB. This is due to CloudKit being a system of eventual consistency. Records can return in sets where they don't have the related data within the same set or out of order. Foreign keys are incompatible with this style of system so we have taken the choice to not support foreign keys after many attempts to do so.