在连接的 DynamoDB 表中传播更改的正确方法是什么

What is the correct way to propogate changes in connected DynamoDB tables

我是无服务器和 dynamoDB 的初学者。我的用例包含两个 tables 行程和路线。 行程 table 包含这些参数 {id, Route, Cost, Distance, Time}。路线 table 包含这些参数 {quantity, Rate, From, To }。

行程 table 中的成本参数由路线 table 中的 quantity * Rate 参数计算得出。每次旅行 created/edited 我从 table 中获取值并将新值存储为旅行 table 的 Cost 参数。

当有人更改路线 table 中的 quantityrate 参数时会出现此问题,我如何将此更改传播到行程 table?目前每次有人更新路由时我都会更新 Cost 参数,有没有更有效的方法?

您可以使用 dynamodb 流。路线 table 中的任何更改都可以在这些流中捕获并进行处理以更新您的行程 table 中的相应对象。不幸的是,DynamoDB 不支持聚合,否则可以在查询对象时计算成本字段,这会容易得多。