Hi. there is something very simple I can't figure ...
# help
n
Hi. there is something very simple I can't figure out. When someone calls
CreateOrder(productsIds: string[])
api, how do I validate those product exists? I mean, how do I organize the folders in a way that its easy to validate this information? For example, if the data is stored in dynamoDB 1. Should I query the dynamoDB products table directly from the service? 2. Should I call the GetProduct() api? Is there any trivial approach here?
r
We typically have a service layer that performs the business logic and a transit layer that exposes API calls that connect to AWS or 3rd party services. For example, with DynamoDB we use OneTable. Each table has multiple schema and models that are set up in one file in the transit layer. Then we have a Data Access Object that exposes specific methods that can be used to access the table via the OneTable models. In your case the DAO might have a getProduct method and a createOrder method.