我找到了 this package .一般来说,它很不错。但是似乎缺少对Projection Expressions的支持.对于 node/typescript 中的 dynamodb,您选择的工具是什么?
我不喜欢列出的数据映射器 here因为它们倾向于包装表数据,或者作为项目被放弃。
最佳答案
如果 typescript 是一个选项,我们使用 https://github.com/shiftcode/dynamo-easy .它也不支持投影表达式,但底层参数始终可以是 accessed and manipulated , 因此添加一些不受支持的功能很容易。
import { DynamoStore } from '@shiftcoders/dynamo-easy'
const queryRequest = new DynamoStore(PersonModel)
.query()
.wherePartitionKey('2018-01')
.whereSortKey().beginsWith('a')
.limit(1)
const queryParams = queryRequest.params
queryParams.ProjectionExpression = 'projectionExpression'
// also add expression attribute names if required
queryParams.ExpressionAttributeNames = {'#someExpressionAttributeName': 'someExpressionAttributeName'}
// you can also use new DynamoDB().query(queryParams), but we just use the preconfigured wrapped client
queryRequest.dynamoDBWrapper.makeRequest('query', queryParams)
.then(r => console.log('first found item with projection expression:', r))
完全披露:我是这个库的作者之一
关于node.js - 亚马逊的 DynamoDB 是否有一个好的查询构建器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46851687/