aws

Ben Sless 2024-10-30T07:59:18.075349Z

I have a dynamodb table with partition keys and range keys in the partition. Which query/expression do I need to write to get all the keys in a partition (using AWS api)?

Ed 2024-10-30T11:22:42.121909Z

Dos this do what you want? (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SQLtoNoSQL.ReadData.Query.html)

// Return all of the songs by an artist

{
    TableName: "Music",
    KeyConditionExpression: "Artist = :a",
    ExpressionAttributeValues: {
        ":a": "No One You Know"
    }
}

Ben Sless 2024-10-30T11:30:32.473639Z

I managed to figure it out by looking at the query sent by AWS console in the network inspector 🙃

{:op :Query
 :request {:ExpressionAttributeNames {"#kn0" "primaryKey"
                                      "#kn1" "rangeKey"}
           :ExpressionAttributeValues {":kv0" {:S "keyValue"}
                                       ":kv1" {:S "prefix"}}
           :KeyConditionExpression "#kn0 = :kv0 and begins_with(#kn1, :kv1)"
           :Limit 50
           :ReturnConsumedCapacity "TOTAL"
           :Select "ALL_ATTRIBUTES"
           :TableName "TableName"}}

👍 1
💯 1
Ben Sless 2024-10-30T11:31:41.918969Z

kn# are key names, put actual key names in the document, kv# are their values