使用 AWS DynamoDB 在 Android 应用程序中使用多个表

Using multiple tables in Android application using AWS DynamoDB

我正在为我的 Android 应用程序使用 AWS DynamoDB 数据库。 我正在使用 AWS Amplify API (GraphQL API) 来查询和变异。

但是,我无法与两个或更多 table 互动。 我想知道如何有目的地使用 2 个或更多 table。我是新手,无法弄清楚。谢谢

您可以简单地创建两个单独的架构,例如:

type Table1 @model {
  id: ID!
  name: String!
  posts: [Post] @connection(name: "BlogPosts")
}

type Table2 @model {
  id: ID!
  title: String!
  blog: Blog @connection(name: "BlogPosts")
  comments: [Comment] @connection(name: "PostComments")
}

您将创建一个 graphql 文件夹,其中将包含两个表的突变、更新和查询的示例代码。