Reputation: 597
How can I get some specific columns from the document below?
For example if I use the following query in data explorer I only get data for single key, but i need to select multiple keys.
Example for retrieving a single key:
r.table('orders_1').get('2786c578-93e1-42d4-a7c4-6f3d7a3a2e00')('orderHeader')('customer_id')
I got 2
as result is 2, which is fine.
But i am not sure on how to select multiple keys and get their values.
Sample document :
orderHeader
{
"id": "2786c578-93e1-42d4-a7c4-6f3d7a3a2e00" ,
"orderHeader": [
{
"created_on": "03-12-2015" ,
"customer_id": "2" ,
"entry_type": "1" ,
"ezp_order_id": "ezp_1333234"
}
]
}
This is what I am trying to achieve:
r.table('orders_1').get('0334cfea-2277-43cb-b8eb-fa360105104a')('orderHeader')('customer_id')(entry_type)
Upvotes: 0
Views: 330
Reputation: 8437
If you want the keys and the values:
r.table('orders_1')
.get('0334cfea-2277-43cb-b8eb-fa360105104a')('orderHeader')
.pluck('customer_id', 'entry_type')
If you only want the values:
r.table('orders_1')
.get('0334cfea-2277-43cb-b8eb-fa360105104a')('orderHeader')
.pluck('customer_id', 'entry_type')
.map(function(d){
return d.values()
})
Upvotes: 2
Reputation: 5289
Does r.table('orders_1').get('0334cfea-2277-43cb-b8eb-fa360105104a')('orderHeader').pluck('customer_id', 'entry_type')
do what you want?
Upvotes: 2