How do I avoid needing to query on multiple primary keys without knowing sort key?

0

I have three different microservices. A metadata service, a 3rd party platform service, and an events service. Each have their own DynamoDB table, and each of those has an index consisting of "pk" and "sk" as primary and sort keys respectively.

In the metadata service's table, pk looks like "CONNECTION#my-user-id" and sk being "SERVICENAME#service-user-id", representing that my app's users can be connected to multiple accounts at multiple 3rd party services.

The 3rd party platform service publishes events to an event bus, which the events service then writes to its table with a pk like "SERVICENAME#service-user-id" and an sk that's a string timestamp.

I would like to enable a user to query my AppSync API for the latest events from their 3rd party platform services. I'm using Cognito as my API's authorizer, so I have the user's "my-user-id" and can query the metadata service's table for all the connections the given user should have. My question is what do I then do with this information, how do I query the events table with only the "SERVICENAME#service-user-id", knowing that there may potentially be many different 3rd party services and user IDs under each of those? BatchGetItem seems like the correct choice, but I don't know an exact sk to pass to that operation. I'm also trying to do this all in AppSync resolvers which adds a fun little spice to the top of this.

I have a feeling I need to change my table schema(s), but would love any help/feedback.

Nick
已提问 1 个月前138 查看次数
没有答案

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则