Git Product home page Git Product logo

harmony's People

Contributors

aaronpearce avatar haiiux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

harmony's Issues

Multiple model variables that include ID interfere with CloudKit sync.

If the user has a model that has more than one object in which has the word ID or id in it, the func nextRecordZoneChangeBatch on Line 192, the return on Line 206 will return a null record. This means that there will be no CloudKit sync possible and there is no specific error reflecting this.

Unsure if this is relevant to #3.

// Bad Model
struct Achievement: HRecord, Codable, Identifiable, Hashable {
    var id: UUID = UUID()
    var achievementID: String
    
    var zoneID: CKRecordZone.ID {
        return CKRecordZone.ID(
            zoneName: "Achievement",
            ownerName: CKCurrentUserDefaultName
        )
    }
    
    var archivedRecordData: Data?
    
    var record: CKRecord {
        let encoder = CKRecordEncoder(zoneID: zoneID)
        return try! encoder.encode(self)
    }
}

// Acceptable Model
struct Achievement: HRecord, Codable, Identifiable, Hashable {
    var id: UUID = UUID()
    var achievementType: String
    
    var zoneID: CKRecordZone.ID {
        return CKRecordZone.ID(
            zoneName: "Achievement",
            ownerName: CKCurrentUserDefaultName
        )
    }
    
    var archivedRecordData: Data?
    
    var record: CKRecord {
        let encoder = CKRecordEncoder(zoneID: zoneID)
        return try! encoder.encode(self)
    }
}

Replacing UUID Requirement?

I started investing Harmony for my project, which has a number of tables and pivot tables. The pivot tables have primary keys that are just the 2 UUIDs for each of the tables it connects. If I understand correctly, Harmony requires HRecord types have a UUID ID, which these pivot tables lack.

I suppose I could add a third column to this table, which would just be a UUID for the row itself, though it isn't technically necessary.

I took a brief shot at refactoring HRecord to use a generic ID that could be encoded/decoded from a String, but the type erasure I tried threw me off.

Do you think this is technically feasible? Is there a reason for the UUID requirement besides ease of implementation?

I don't mind taking a shot at implementation

Add error for missing modelTypes.

Need to add an error to the function at Line 427 to handle missing model types in the syncable list.

    func modelType(for recordType: String) -> (any HRecord.Type)? {
        guard let modelType = self.modelTypes.first(where: { t in
            return t.recordType == recordType
        }) else {
            // Add error!
            return nil
        }

        return modelType
    }

Create Testing Host/Demo App

As we require the CloudKit entitlement to test, we'll need to create a test host app to provide the ability for testing of the library.

This app could also be dual purpose as a demo application.

Revisit Record ID system

We should revisit the record ID system and see if we can provide a better way to get record type from the system alongside the actual identifier.

Currently we merge the record type and identifier into a singular identifier for pushing to CloudKit.

We could look to keep a local mapping of identifier to record type in GRDB, or continue with the current system with some improvements.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.