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
[Gen2] Add sort key to model identifier #13201
Comments
Hello, @ryanmalesic 👋 and thank you for opening this issue. It looks like you're referring to the Gen2 Developer Experience with this feature request. Just to confirm, have you reviewed the composite identifier section that shows how to use a sort key within the The first string that's passed into the array is the partition key. The second (and any more) would be additional sort keys. |
Thanks. I guess my request then is updating the docs to explicitly call out that subsequent items are sort keys and NOT 1 PK with all the fields joined is needed then: https://docs.amplify.aws/gen2/build-a-backend/data/data-modeling/identifiers/#pageMain |
Also, it seems sort keys on the primary index don't support comparison operations in the autogenerated gets/queries? Is this correct |
Hi @ryanmalesic can you explain your use case a bit more? When performing a const schema = a.schema({
Customer: a
.model({
name: a.string(),
phoneNumber: a.phone().required(),
accountRepresentativeId: a.id().required(),
})
.identifier(["accountRepresentativeId", "phoneNumber"])
.authorization([a.allow.owner()]),
}); If this doesn't fit your use case either, then can you provide an example of your schema and the data access pattern you're trying to achieve? |
Understood on the get, that was a mistype. Does list + filter convert to a Scan + Filter expression or a Query when calling DDB from the default generated app sync resolver? If it's scan + filter, this is too unoptimized and comparatively expensive to a Query for my use-cases. Dynamo makes a point to discourage scan usage for things that could be queries My use case would involve having a method called query (for example) on the generated model that accepts the pk and then optionally a query (beginsWith, lt, gt, etc) operation on the (composite) sort key. This would translate to a Query operation on the table in the resolver function Also having a composite pk would be helpful. Instead of identifier having the first field of the array be the pk and the rest becoming a composite sk, it could be something like
|
Is this related to a new or existing framework?
No response
Is this related to a new or existing API?
GraphQL API
Is this related to another service?
DynamoDB
Describe the feature you'd like to request
.identifier()
on models should allow for sort keys.Describe the solution you'd like
.identifier({ hashKey: [...], sortKey: [...] })
Describe alternatives you've considered
GSIs with sort keys don't fit my use-case as duplicates are allowed in GSIs
Additional context
No response
Is this something that you'd be interested in working on?
The text was updated successfully, but these errors were encountered: