amazon-dynamodb - 具有跨多对多关系过滤的 Amplify/DynamoDB 请求数据表
问题描述
我尝试通过多对多关系过滤来请求表,但在放大 graphql 或 dynamoDB 上似乎是不可能的。
我有三个关系表。品牌、主题、产品类型。
我的问题是:如何通过 topicId 和 ProductTypeID 过滤来选择所有品牌?
无论解决方案如何,dynamoDb sdk、弹性@searchable 数据、扫描 dynamo db、partiQL,直接在 graphql 解析器上。我随便拿。
这是我的graphql架构:
type Topic @model
@key(name: "topicByName", fields: ["name"])
@searchable
{
id: ID!
name: String!
color: String
icon: String
brands: [BrandTopic] @connection(keyName: "byTopic", fields: ["id"])
}
type BrandTopic @model
@key(name: "byTopic", fields: ["topicID", "brandID"])
@key(name: "byBrand", fields: ["brandID", "topicID"])
{
id: ID!
topicID: ID!
brandID: ID!
topic: Topic! @connection(fields: ["topicID"])
brand: Brand! @connection(fields: ["brandID"])
}
type ProductType @model
@key(name: "productTypesByName", fields: ["name"])
@searchable
{
id: ID!
name: String!
color: String
icon: String
brands: [BrandProductType] @connection(keyName: "byProductType", fields: ["id"])
}
type BrandProductType @model(queries: null)
@key(name: "byProductType", fields: ["productTypeID", "brandID"])
@key(name: "byBrand", fields: ["brandID", "productTypeID"])
{
id: ID!
productTypeID: ID!
brandID: ID!
productType: ProductType! @connection(fields: ["productTypeID"])
brand: Brand! @connection(fields: ["brandID"])
}
type Brand @model
@key(name: "ByName", fields: ["name"])
@searchable
{
id: ID!
name: String!
link: String
image: String
bio: String
topics: [BrandTopic] @connection(keyName: "byBrand", fields: ["id"])
productTypes: [BrandProductType] @connection(keyName: "byBrand", fields: ["id"])
createdAt: AWSDateTime! #important to keep it to have filter with keys
updatedAt: AWSDateTime! #important to keep it to have filter with keys
}
解决方案
推荐阅读
- ionic-framework - 振动在后台模式下不起作用(离子/电容器))
- web - 如何在单个域上提供 2 个不同版本的网站是可能的?
- anylogic - 在anylogic中按计划使用资源
- javascript - Content doesn't show in the modal
- wordpress - Woocommerce custome field value editable n product page
- html - why when I use fullscreen on my web the images is zooming too
- c# - winform change checkbox's color of the actual box
- sql - Oracle - 不使用 XMLAGG 将列值转换为 CLOB 形式的逗号分隔值
- reactjs - How to add Tradingview's Lightweight-charts to React Typescript
- amazon-web-services - Restrict S3 objects URL only to logged in users on a website