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 个月前

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

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

回答问题的准则