问题描述
背景
在使用 AWS Amplify JS 时,特别是开发工具包的 DataStore
部分时,您在 schema.graphql
中指定的每个模型都会获得一个关联的 DynamoDB 表:>
schema.graphql
type Blog @model {
id: ID!
name: String!
posts: [Post] @connection(name: "BlogPosts")
}
type Post @model {
id: ID!
title: String!
blog: Blog @connection(name: "BlogPosts")
comments: [Comment] @connection(name: "PostComments")
}
type Comment @model {
id: ID!
content: String
post: Post @connection(name: "PostComments")
}
这对应于在 AWS 中创建的 4 个 DynamoDB 表
-
Blog-somerandomstring-dev
—(有道理) -
Post-somerandomstring-dev
—(有道理) -
Comment-somerandomstring-dev
—(有道理) -
AmplifyDataStore-somerandomstring-dev
—(这张桌子是从哪里来的?)
问题
鉴于上述情况,这个额外表 (AmplifyDataStore-somerandomstring-dev
) 背后的解释和/或功能是什么?
解决方法
答案
这个额外的表,不是由您的 Amplify Graphql 架构中的任何特定 @model
创建的,称为 Delta Sync Table,其目的是帮助冲突检测和同步
这可能意义不大,但 doc 的其余部分说明了 Amplify/AppSync 如何解决您的数据冲突。