DynamoDB Javascript – Query by primary key and array of range keys?

前端 未结 2 2062
庸人自扰
庸人自扰 2020-12-17 21:51

New to DynamoDB and need to do the above query, but not sure how. Here is what I\'m trying currently, and I\'m getting the error below.

Btw, I am using this javascr

2条回答
  •  甜味超标
    2020-12-17 22:27

    KeyConditions does not support the IN operator. The documentation for KeyCondition says what operators it does support:

    For KeyConditions, only the following comparison operators are supported:

    EQ | LE | LT | GE | GT | BEGINS_WITH | BETWEEN

    The EQ operator only works for a single value as well:

    • EQ : Equal.

      AttributeValueList can contain only one AttributeValue of type String, Number, or Binary (not a set type). If an item contains an AttributeValue element of a different type than the one specified in the request, the value does not match. For example, {"S":"6"} does not equal {"N":"6"}. Also, {"N":"6"} does not equal {"NS":["6", "2", "1"]}.

    The restrictions are basically the same for KeyConditionExpression, which is the newer, recommended way for filtering on keys. Here is a snippet from the documentation (emphasis mine):

    The condition must perform an equality test on a single hash key value. The condition can also perform one of several comparison tests on a single range key value. Query can use KeyConditionExpression to retrieve one item with a given hash and range key value, or several items that have the same hash key value but different range key values

    In your case, you could build out the FilterExpression in a similar way as described in this answer.

提交回复
热议问题