RethinkDB, add derived columns on result -
i can seem via map+merge
map( function(row) { return row.merge( { newcol: 'abc' } ); });
problem if want lookup static map e.g.
var lookup_map = {key1: {text: 'key 1'}};
then below doesn't work
map( function(row) { return row.merge({ newcol: lookup_map[row('key')].text }); });
row('key'); seems lazily evaluated. idea how this?
you can use sth this:
var lookup_map = {key1: {text: 'key 1'}}; r.db('salaries').table('salaries') .map( function(row) { return row.merge({ newcol: r.expr(lookup_map)(row('key'))('text') }); });
Comments
Post a Comment