-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(datastore): support of custom primary key #1641
Conversation
ee39794
to
9c16236
Compare
9c16236
to
5a97c8a
Compare
5a97c8a
to
d208a7b
Compare
packages/amplify_datastore/ios/Classes/utils/modelHelpers.swift
Outdated
Show resolved
Hide resolved
@@ -30,7 +30,6 @@ class FlutterSubscriptionDataProcessedEvent( | |||
"modelName" to model.modelName, | |||
"element" to mapOf( | |||
"syncMetadata" to mapOf( | |||
"id" to syncMetadata.id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this important to include?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With custom primary key, id is no longer a mandatory field.
Model identifier (either transition single id
field, or a composite key formed by multiple model fields) can always be determined by schema + model fields values. In addition, this field has not been used any where. So this field can be safely removed.
fun toValueMap(): Map<String, Any?> { | ||
return mapOf( | ||
"id" to this.metadata.model.id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question -
Isn't this important to include?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
.modelSchema(schema) | ||
.serializedData(serializedModelData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing the order here matters which is why you've made the change throughout? If that's the case, can we possibly create a wrapper class/method that abstracts away the need to remember this? It seems like an easy thing to miss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's due to builder step interface change in amplify-android.
We don't need to remember the order, compiler will let us know if the order is wrong. So we don't need a wrapper either.
cc9babb
to
1a50262
Compare
- CRLF to LF - Source code reformatting and fixing linter issues
b9afc16
to
90f1a44
Compare
- Add ModelIndex ModelIdentifier interface - Make Model non-abstract class to prevent unnecessary breaking changes - Add indexes to model schema - Add query by model identifier interface
90f1a44
to
6470937
Compare
6470937
to
3f81e0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left one comment about mavenLocal, otherwise LGTM.
!!Do not merge until required versions of amplify-ios and amplify-android are released.
Recommend to review by commit.
PR checks will fail as required amplify-ios and amplify-android interface changes do not exist yet.
Issue #, if available:
#1426
Description of changes:
Pending Changes
[ ] GraphQL API model helper user case(out of scope)By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.