1 | var once = require('once'),
|
2 | db = require('../db')
|
3 |
|
4 | module.exports = function listTables(store, data, cb) {
|
5 | cb = once(cb)
|
6 | var opts, limit = data.Limit || 100
|
7 |
|
8 | if (data.ExclusiveStartTableName)
|
9 | opts = {gt: data.ExclusiveStartTableName}
|
10 |
|
11 | db.lazy(store.tableDb.createKeyStream(opts), cb)
|
12 | .take(limit + 1)
|
13 | .join(function(names) {
|
14 | var result = {}
|
15 | if (names.length > limit) {
|
16 | names.splice(limit)
|
17 | result.LastEvaluatedTableName = names[names.length - 1]
|
18 | }
|
19 | result.TableNames = names
|
20 | cb(null, result)
|
21 | })
|
22 | }
|