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

asked 4 months ago166 views
3 Answers
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
EXPERT
answered 4 months ago
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.

answered 4 months ago
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?

answered 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions