pythonrethinkdbrethinkdb-pythonnosql

Rethinkdb: returning more than one object from a query


I have a table with some rows that look like this:

{
  "id": "12345"
  "created_date": Fri May 27 2016 22:06:25 GMT+00:00 ,
  "image": true

} {
  "id": "6789"
  "created_date": Mon May 30 2016 07:48:35 GMT+00:00 ,
  "video": true

}{
  "id": "12345"
  "created_date": Fri May 21 2016 22:06:25 GMT+00:00 ,
  "image": true

} {
  "id": "6789"
  "created_date": Mon May 6 2016 07:48:35 GMT+00:00 ,
  "video": true

}
etc...

I would like to return the latest (newest, earliest date) object that has "video":true in addition to this I want return the latest object that has "image":true.

BUT, I want to do this in one query, since this will ultimately be done on the same table.

Ideally the answer would be:

[{
      "id": "12345"
      "created_date": Fri May 27 2016 22:06:25 GMT+00:00 ,
      "image": true

    }, {
      "id": "6789"
      "created_date": Mon May 30 2016 07:48:35 GMT+00:00 ,
      "video": true

    }]

Is there anyway to do this?


Solution

  • You can combine two queries by writing something like r.expr([query1, query2]) and it should work.