3 ms·
You can do that too: r.table('foo').filter(r['bar'] > 5) The use of r in filter is getting the attribute bar of the row.
by coffeemug 14y ago
You can do that too: r.table('foo').filter(r['bar'] > 5)
The use of r in filter is getting the attribute bar of the row.
- lucian1900 14y agoThat's pretty cool. Have you found that there are useful expressions that are awkward to express without the lambda trick?
- coffeemug 14y agoLambda is necessary because when you do nested subqueries, saying r['x'] is ambiguous and can cause all sorts of unpleasantness. So, if you use nested queries, the server rejects the implicit syntax and requires the use of lambda. Lambda syntax is really nice too, I actually prefer it for writing queries.
- lucian1900 14y agoI find the lambda trick not explicit and obvious enough. I fear I would do something stupid like trigger a side-effect without realising. Again taking an example from SQLAlchemy, you can explicitly make a subquery, and then reference it instead of the original Table. A binding more like SQLAlchemy can probably written for RethinkDB.