Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in AWS by (50.2k points)

Is there a way to get items depending on a field but not a hash key?

Example

My Table: id (HashKey), name, email

How this can be done ??

I try this with boto :

user = users.get_item(email='[email protected]')

I get the following error :

'The provided key element does not match the schema'

1 Answer

+1 vote
by (107k points)

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

Inexplicably, the possible solution conflicts with all AWS documentation that I can get.

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)

});

You might also wanna read AWS Tutorial to have a better understanding of the concepts of AWS. 

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...