Filtering AWS DynamoDB Orders by Users's Accessible Company Codes

0

I'm working on an AWS DynamoDB setup where orders are stored, each associated with a company code. In our admin portal, I'm aiming to display orders based on the company codes accessible to the logged-in admin. Admins may have access to multiple company codes, and I need to filter and display orders belonging to these respective company codes.

How can I efficiently retrieve orders from DynamoDB that correspond only to the company codes accessible by a specific admin? Are there specific DynamoDB query patterns or best practices to manage and retrieve orders associated with multiple company codes based on an admin's access permissions

已提問 4 個月前檢視次數 177 次
3 個答案
1

You simply create a GlobalSecondaryIndex (GSI) on CompanyCode in which you group the data by that field. For every CompanyCode that the admin is allowed to view, you must issue a Query. For example, if they were allowed to see 10 companies orders, you would make 10 concurrent requests to the GSI.

You can read about best practices for using indexes here

profile pictureAWS
專家
已回答 4 個月前
0

Looks like you need an index on "company codes" attribute, but will be easier to answer if you post the current table structure with some sample data.

已回答 4 個月前
0

@carlos Thanks you for your response, Sample Data

I currently have an index for the Company Code in my DynamoDB dataset. Consider the sample data provided. I've implemented a solution for Admin A, who has access to Company#5100, to retrieve the data in a single query.

Now, I'm dealing with Admin B, who has access to both Company#5100 and Company#7100. Instead of querying data for both companies separately and concatenating the responses, I'm seeking a more efficient approach. What could be a better strategy to handle this scenario for Admin B with access to multiple companies?

已回答 4 個月前

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

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

回答問題指南