Question

I have a field bidder with arrays and objects like this(it can be also empty):

[
   [
      {
         "date":"08/17/1999"
      },
      {
         "time":"07:15:23"
      },
      {
         "increase":31.5
      }
   ],
   [
      {
         "date":"04/01/1998"
      },
      {
         "time":"01:06:18"
      },
      {
         "increase":10.5
      }
   ]
]

How can I select first-array's increase value that means output should be 31.5.

Was it helpful?

Solution

In JavaScript

r.table('test')('bidder').nth(0)('increase').run(conn, callback)

In Python and Ruby

r.table('test')['bidder'][0]['increase'].run(conn)

Edit: Queries for all documents If you need to do more complex things that just returning a value, you can use the general "form" with map

r.table('test').map(function(doc) {
   return doc('bidder').nth(0)('increase')
}).run(conn, callback)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top