@awspilot/dynamodb

Issue Star Fork
scan.js
recursive_scan.js
index_scan.js
// optionally you can limit the returned attributes with .select() // and the number of results with .limit() DynamoDB .table('cities') .select('name','country','object.attribute','string_set[0]','array[1]') .having('country').eq('Canada') .limit(10) .scan(function( err, data ) { console.log( err, data ) });
// continous scan until end of table (function recursive_call( $lastKey ) { DynamoDB .table('cities') .resume($lastKey) .limit(1000) .scan(function( err, data ) { // handle error, process data ... if (err) return console.log(err) console.log("scanned", data.length, " items") if (this.LastEvaluatedKey === null) { // reached end, do a callback() maybe return console.log('---| end of cities'); } var $this = this setTimeout(function() { recursive_call($this.LastEvaluatedKey); },1000); // add delay between scans, if necessary }) })(null);
// GSI index scan DynamoDB .table('cities') .index('country-index') .scan(function( err, data ) { console.log( err, data ) });