DynamoDB : The provided key element does not match the schema

0 votes

Is there a way to get item depending on a field but not hashkey?

Example

My Table: id (HashKey) , name , email

How this can be done ??

I try this with boto :

user = users.get_item(email='john.doe@gmail.com')

I get the following error :

'The provided key element does not match the schema'

Nov 13, 2018 in AWS by findingbugs
• 3,170 points
2,901 views

1 answer to this question.

0 votes

The following applies to the Node.js AWS SDK in the AWS Lambda environment: 

I finally found a solution on the AWS forum: https://forums.aws.amazon.com/thread.jspa?threadID=208820

Inexplicably, the apparent solution conflicts with all AWS documentation that I can find.

Here is the code which worked for me:

var doc = require('dynamodb-doc');
var dynamo = new doc.DynamoDB();

var params = { }
params.TableName = "ExampleTable";
var key = { "ExampleHashKey": "1" };
params.Key = key;

dynamo.getItem(params, function(err, data) {
    if (err)
        console.log(err);
    else
        console.log(data)
});
answered Nov 13, 2018 by Priyaj
• 56,900 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer

Trying to Determine Amazon EC2 instance creation date/time

You can't find as such attribute called ...READ MORE

answered May 29, 2018 in AWS by Flying geek
• 3,160 points
2,325 views
0 votes
1 answer

How to launch and configure an EMR cluster using boto

Boto and the underlying EMR API is ...READ MORE

answered Sep 12, 2018 in AWS by Priyaj
• 56,900 points
1,114 views
0 votes
1 answer
+3 votes
3 answers