Ben
Ben

Reputation: 2269

Move object values from objec to array in RethinkDB

I cannot figure out how to convert objects into a JsonArray.

r.db('data').table('user').filter({'_deleted':false}).pluck(['id'])

My result looks like this:

{
   "id":  "10008590"
}, 
{
   "id":  "10006821"
}

And i want it to look like this:

[ "10008590", "10006821"]

what do i add to a query after .pluck()?

Upvotes: 0

Views: 129

Answers (1)

taygetos
taygetos

Reputation: 3040

Simple, after the pluck() you use the map() function to extract the id field:

.map(function(doc){return doc('id')})

in shorter form:

.map(r.row('id'))

Note: in the UI i also needed .coerceTo("array") to the end

Upvotes: 1

Related Questions