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.

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠