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 次
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南