Created
June 17, 2019 20:16
-
-
Save ekkis/fb48aa4c567cf1a4653c809c2a5f20e6 to your computer and use it in GitHub Desktop.
Retrieving data from EOS tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table: async (table, opts = {}) => { | |
var eos = await self.init(opts); | |
var r, next = 0, ret = []; | |
do { | |
r = await eos.rpc.get_table_rows({ | |
table, | |
code: opts.code || CONTRACT, | |
scope: opts.scope || ACCT, | |
limit: opts.limit || 100, | |
lower_bound: next, | |
json: true | |
}); | |
let rows = r.rows; | |
next = rows[rows.length - 1].id + 1; | |
if (opts.filter) rows = rows.filter(opts.filter); | |
ret = ret.concat(rows); | |
} while (r.more); | |
return ret; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment