I'm implementing simple webapp using horizon backend and reactjs frontend. I need to get a collection (table) grouped by specific field. Then I need to order each reduction by another field and limit records in each reduction to 1. Reql query that returns what I need:
r.db('reporter').table('reports')
.group('project_name')
.orderBy(r.desc('time_created'))
.limit(1)
I did not find relevant methods (group) in documentation (http://horizon.io/api/collection/). I'm aware that I may have misunderstood role of Collection object - from my current understanding it is a direct proxy to rethinkdb table and all operations available on table should be available on collection - am I wrong? Is there intermediate layer that I need to implement to get this behaviour?
The Horizon API is much more limited than the RethinkDB API. The only methods defined on collections are the ones listed at http://horizon.io/api/collection/ . If you need more complicated behavior, you can embed Horizon in a NodeJS app and define a custom endpoint that issues any ReQL query you want: http://horizon.io/docs/embed/ .