我正在 AWS Amplify 中使用 graphql 为新的 DynamoDB 创建我的第一个架构。我注意到许多示例中没有 @key 指令来定义主键,例如下面的“产品”:
type Inventory @model
@key(name: "byWarehouseID", fields: ["warehouseID"], queryField: "itemsByWarehouseID")
@key(fields: ["productID", "warehouseID"]) {
productID: ID!
warehouseID: ID!
inventoryAmount: Int!
}
type Product @model {
id: ID!
name: String!
orders: [Order] @connection(keyName: "byProduct", fields: ["id"])
inventories: [Inventory] @connection(fields: ["id"])
}
Run Code Online (Sandbox Code Playgroud)
第一个字段是否自动用作主键(分区键)?
amazon-dynamodb graphql react-native aws-appsync aws-amplify