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.

回答なし

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ