Skip to content

Instantly share code, notes, and snippets.

@ekkis
Created June 17, 2019 20:16
Show Gist options
  • Save ekkis/fb48aa4c567cf1a4653c809c2a5f20e6 to your computer and use it in GitHub Desktop.
Save ekkis/fb48aa4c567cf1a4653c809c2a5f20e6 to your computer and use it in GitHub Desktop.
Retrieving data from EOS tables
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