Question

I have a table with records like this

{
 a:{aa:"aa1",aaa:"aaa1"},
 b:"b1",
 ...
},
{
 a:{aaa:"aaa2"},
 b:"b2",
 ...
},
{
 a:{aa:"aa3"},
 b:"b3",
 ...
},

and I want to extract aa and b values, i.e. to something like

{aa:"aa1",b:"b1"},
{aa:undefined,b:"b2"},
{aa:"aa3",b:"b3"},
Was it helpful?

Solution

You can write something like:

o = {a: {aa: "aa1", aaa: "aaa1"}, b: "b1"}
r.expr(o).do({a: r.row('a')('aa').default(null), b: r.row('b').default(null)})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top