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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -