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
817 stars 106 forks source link

The provided key element does not match the schema [ES6] #154

Closed jaiminvaja-cue closed 5 years ago

jaiminvaja-cue commented 5 years ago

Hey @garnaat @bdonlan @jupiter @trevorrowe @jpeddicord

I really appreciate your work. I am new to TS.

I understand ES6, but don't understand how could I fix the below error. I hope it would be easy to share solution.

(node:9249) UnhandledPromiseRejectionWarning: ValidationException: The provided key element does not match the schema```

This is my ES6 JS file.
import {
    DynamoDbSchema,
    DynamoDbTable,
} from '@aws/dynamodb-data-mapper';

class MovieModel {
    constructor(year, title) {
        this.year = year;
        this.title = title;
    }
}

Object.defineProperties(MovieModel.prototype, {
    [DynamoDbTable]: {
        value: 'Movies'
    },
    [DynamoDbSchema]: {
        value: {
            year: {
                type: 'Number',
                keyType: 'HASH'
            },
            title: {
                title: 'String'
            }
        },
    },
});

export default MovieModel;

Your guidance will be highly appreciated and valuable to me. Regards,

jaiminvaja-cue commented 5 years ago

Review the below link to get solution: https://github.com/awslabs/dynamodb-data-mapper-js/tree/master/packages/dynamodb-data-marshaller