3 ms·
Here's what this query looks like in RethinkDB (also based on JSON documents): r.table('orders') .pluck('cust_id','ord_date','price') .groupBy('cust_id
by mglukhovsky 14y ago
Here's what this query looks like in RethinkDB (also based on JSON documents):
r.table('orders')
.pluck('cust_id','ord_date','price')
.groupBy('cust_id','ord_date', r.sum('price')).
.filter(r.row('reduction').gt(250))
We use the hard-coded attribute 'reduction' because groupBy automatically gets compiled to our distributed map-reduce infrastructure. There is currently no as command (though it could easily be simulated with map). I'll add a GitHub issue for this shortly, since we should add sugar for it.
- Goopplesoft 14y agoMost ORMs use dot notation, even for mongo (e.g. mongo engine) to build queries. I think the mongo queries are more true to what it should be since dot notation in most languages implies a function/method is being called and order matters in those cases. Here it's just acting like a query builder that runs with .run(). Under the same effect I'm not a fan of mongo style query({}).limit(count).skip(num) format and usually I move the limit and skip into the initial query.
- greendestiny 14y agoThe beauty of JSON is you could incredibly easily write such jquery like chained expression to generate the mongo query. JSON is a good ascii representation of structured data thats compact, quite readable and reasonably human editable. Its not an abuse of JSON to use it as a way of representing queries, but its probably a shame that Mongo haven't provided a better way of generating queries.
- sm_sohan 14y agoTotally agree with you.
- istvanp 14y agoWhat are the main differences between MongoDB and RethinkDB? Things that you hear people care about? I don't use Mongo but I've seen projects that use it. I ask because I want to store & retrieve some analytics. After seeing the screencast of RethinkDB it seems to me that it's just like Mongo but a much better API and easier handling of sharding and replication. The only con I see of using RethinkDB is that it's very new (so is Mongo...) and probably is little too early for production. Basically I hope not to find worse surprises down the road than I hear of Mongo :P
- coffeemug 14y agoWe're going to publish some comparisons in a few days, but basically you nailed it (both pros and con). We're trying to build a stellar data-oriented development environment/query language, and a stellar scalability infrastructure. All the main pieces are there, and Rethink is a lot of fun to use. The rough edges will be polished out in over the next few months.