@awspilot/dynamodb

Issue Star Fork
scan.js
recursive_scan.js
index_scan.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// 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 )
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 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);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
// GSI index scan
DynamoDB
.table('cities')
.index('country-index')
.scan(function( err, data ) {
console.log( err, data )
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Describe Execute
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX