-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Feature Request
When using .forceReplace operations, the response doesn't indicate whether a record was created or updated. This makes it difficult to provide detailed sync summaries showing what actually changed.
Current Behavior
modifyRecords() returns [RecordInfo] which includes:
recordName,recordType,recordChangeTag,fieldsisErrorfor detecting failures
But there's no indication whether the operation resulted in a create or an update.
Proposed Solutions
1. Add field to RecordInfo (if CloudKit API provides it):
public struct RecordInfo {
// ... existing fields ...
public let wasCreated: Bool? // true if newly created, false if updated
}2. Provide helper for pre-fetch pattern:
extension RecordManaging {
func classifyOperations(
_ records: [some CloudKitRecord],
existingNames: Set<String>
) -> (creates: [RecordOperation], updates: [RecordOperation])
}3. Document the pattern in MistKit examples/documentation
Use Case
Sync operations that need to report detailed statistics:
- "Created: 5, Updated: 20, Failed: 0"
- GitHub Actions summaries showing what changed
- Audit logs tracking data changes
Workaround
Currently using a pre-fetch strategy (query existing record names before sync), but native support would be cleaner.
Reference Implementation
BushelCloud implements this pattern:
OperationClassificationstruct: classifies operations by comparing proposed records against existing CloudKit recordsfetchExistingRecordNames(): queries CloudKit for existing record namesexecuteBatchOperations(): tracks creates/updates/failures based on classification
This works well but requires an extra CloudKit query before each sync operation (~600ms overhead for 3 record types).