How to use ExclusiveStartKey

xiepeng edited this page Jan 22, 2012 · 2 revisions
Clone this wiki locally

In some cases the result set is too big, DynamoDB will return only a subset of the results. The LastEvaluatedKey can be passed to the next query as ExclusiveStartKey.

var scanDynamoDB = function(query) {        
    dynamoDB.scan( query , function(response, result) {
        result.on('ready', function(data){
            console.log(data.Items);    // Print out the subset of results.
            if(data.LastEvaluatedKey) { // Result is incomplete; there is more to come.
                query.ExclusiveStartKey = data.LastEvaluatedKey;

var query = {"TableName":"Table1",
         "Limit": 2, // This request asks for 2 items at a time
         "AttributesToGet":["Color", "Weight", "Name"]