What Is The Correct Way To Propogate Changes In Connected DynamoDB Tables
I'm a beginner in Serverless and dynamoDB. My use case consists of two tables Trips and Routes.
Trips table consists of these parameters {id, Route, Cost, Distance, Time}
. Routes table consists of these parameters {quantity, Rate, From, To }.
Cost param in the Trips table is calculated by quantity * Rate
params from the routes table. Every time a trip is created/edited I fetch the value from the table and store the new value as Cost
param of trips table.
The issue arises when someone changes the quantity
or rate
parameter in the Routes table, how do I propogate this change to Trips table? Currently I'm updating the Cost
Parameter everytime someone updates Routes, is there a more efficient way?
Answer
You can use dynamodb streams. Any change in the route table can be captured in these streams and processed to update the corresponding object in your Trips table. DynamoDB does not support aggregations unfortunately otherwise the cost field could have been computed while querying the object which would have been a lot easier.
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM