1
votes

I am trying query the values in dynamoDB and I have still the error.
Date is ISO-8601 (String) = createdAt and is it sort key.

My params:

{
    TableName: 'Pool',
    ExpressionAttributeValues: { ':oin': 'lol', ':from': '2017-12-16T20:26:02.594Z' },
    KeyConditionExpression: 'oin = :oin',
    ConditionExpression: 'createdAt >= :from',
    ProjectionExpression: 'createdAt, h10m, h30m, h1h, h24h, accepted, stale, dupl, oth',
    ScanIndexForward: false
}

I try GE with same result.

I generate the date with this code in Node.js:

var date = new Date();
date.setHours(date.getHours()-24);
var dateiso = date.toISOString();

I get following error:

ValidationException: Value provided in ExpressionAttributeValues unused in expressions: keys: {:from}

Any idea how to solve ConditionExpression? Thank you

1

1 Answers

2
votes

The error message seems to indicate that you have an unused ExpressionAttributeValue of :from.

The ConditionExpression attribute that you specified can only be used for an Update, Delete and PutItem operation. If the createdAt attribute is a sort key, you want to specify that in the KeyConditionExpression along with oin.

For example:

KeyConditionExpression: 'oin = :oin AND createdAt >= :from'