Skip to content

Commit

Permalink
fix: support expression attrbitube names in projection expressions. (#27
Browse files Browse the repository at this point in the history
)
  • Loading branch information
thantos authored Apr 13, 2022
1 parent 2ca185f commit 8c3c220
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type QueryInput<
> &
ExpressionAttributeNames<KeyConditionExpression> &
ExpressionAttributeNames<FilterExpression> &
ExpressionAttributeNames<ProjectionExpression> &
ExpressionAttributeValues<KeyConditionExpression, Format> &
ExpressionAttributeValues<FilterExpression, Format> & {
KeyConditionExpression?: KeyConditionExpression;
Expand Down
18 changes: 18 additions & 0 deletions test/v2-document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ export async function foo(userId: string) {
})
.promise();

// using only projection
await table
.query({
TableName: "TableName",
AttributesToGet: ["attr"],
KeyConditionExpression: "key = :val",
FilterExpression: "key2 = :val2",
ProjectionExpression: "#key1",
ExpressionAttributeNames: {
"#key1": "",
},
ExpressionAttributeValues: {
":val": "val",
":val2": true,
},
})
.promise();

if (response.Items) {
response.Items[0].attr;
}
Expand Down

0 comments on commit 8c3c220

Please sign in to comment.