0
votes

This is the query:

                var params = {
                    TableName : "events",
                    KeyConditionExpression: "event = :event",
                    ExpressionAttributeValues: {
                        ":event": "florida"
                    }
                };
                db.query(params, function(err, data) {
                    if (err) console.log(err, err.stack);
                    else     console.log(data);
                })

This is the error:

message: 'Query condition missed key schema element: id', code: 'ValidationException',

What am I doing wrong here?

Table looks like this:

id division_id event

1491934519379 111222 florida
1491934895527 222111 florida
1491936271559 232123 earthquake
1491936037958 543335 los angeles
1491936037957 554334 los angeles

1

1 Answers

2
votes

It looks like you're trying to query by a non-key value (event).

You'll need to either query by id, or set up a global secondary index (GSI), using your event column as the index hash key.

You can create a GSI by calling UpdateTable.

Once you create the index, you'll be able to call Query with your IndexName, to query records by event.