Update: now you can use @primarykey and @index annotations:
https://docs.amplify.aws/cli/migration/transformer-migration/#what-is-changing
basic:
profile @model {
name
email @primaryKey - has to be unique
other
}
so if you needed something like:
profile @model {
name
email: String! @hasOne
other
}
email @model {
email: String! @primaryKey
}
if you are on an older version see below
I will eventually be testing this out to see if this works but you might be able to do something like rename the id to a string!
so...
type Tag @model @key["id"] {
id: String!
}
or:
type Customer @model @key(fields: ["email"]) {
email: String!
username: String
}
this second one is taken directly from the docs: https://docs.amplify.aws/cli/graphql-transformer/key#designing-data-models-using-key
The docs were updated recently so hopefully they are easier for everyone to understand.
If you need a more advanced workflow with allot of keys, and stuff like that then you just have to separate things out and make more types for example:
type Customer @model {
id: String!
email: Email! @hasOne
username: String
}
type email @model @key(fields: ["email"]) {
email: String!
}