awslabs / dynamodb-data-mapper-js

A schema-based data mapper for Amazon DynamoDB.
https://awslabs.github.io/dynamodb-data-mapper-js/
Apache License 2.0
816 stars 106 forks source link

`executeUpdateExpression` matches key attibutes with variable name in Model Class instead of @rangeKey({attributeName: '<>'}) #197

Open krishmakochhar opened 3 years ago

krishmakochhar commented 3 years ago

If your model is like this :

export class Model {
    @hashKey({attributeName: 'HashKey'})
    private _hashKey!: string;

    @rangeKey({attributeName: 'SortKey'})
    private _sortKey!: string;

And if I try to use the executeUpdateExpression method as :

const itemKey = {
            HashKey: <some-key>,
            SortKey: <some-key>,
        };
        await this.mapper.executeUpdateExpression(updateExpression, itemKey, noArgsConstructor);

We get “The provided key element does not match the schema” error. But it works fine if use this instead :

const itemKey = {
            _hashKey: <some-key>,
            _sortKey: <some-key>,
        };
        await this.mapper.executeUpdateExpression(updateExpression, itemKey, noArgsConstructor);