noppoMan / npdynamodb

A Node.js Simple Query Builder and ORM for AWS DynamoDB
112 stars 19 forks source link

How to use ExclusiveStartKey? #32

Closed mave99a closed 8 years ago

mave99a commented 8 years ago

I used limit() in the query and it works as expected, and I got LastEvaluatedKey from the result.

The question is, how to pass this as ExclusiveStartKey in the next query? Thanks!

noppoMan commented 8 years ago

@mave99a Thanks for using npdynamodb!

You can pass LastEvaluatedKey to exclusiveStartKey method in feature method callback. Here is example.

For Query Builder

npd().table("foo").limit(10).feature(function(f){
  f.exclusiveStartKey(LastEvaluatedKey);
}).then(function(results){
  console.log(results);
});

For ORM

Model.query(function(qb){
  qb.limit(10);
  qb.feature(function(f){
   f.exclusiveStartKey(LastEvaluatedKey);
  });
}).then(function(results){
  console.log(results);
});

Feature api has grouped non required parameters for each operations of Dynamodb api version 2012-08-10. Other methods that are grouped in feature is here. https://github.com/noppoMan/npdynamodb#feature-methods-2012-08-10

Sorry for your confusing but I'm considering to make offset method to pass LastEvaluatedKey that is like sql interface.

Thanks!

mave99a commented 8 years ago

Thanks a lot! It worked perfectly!

mave99a commented 8 years ago

Close this issue.