Re:A Comprehensive Guide to Moving from SQL to RethinkDB
by atnnn on Tuesday April 07, 2015 @01:56PM
(#9335810)
The RethinkDB query language can be very expressive.
What you shudder to think of could be expressed as
row('species').contains(function(s){ r.expr(['Saiyan', 'Human', 'Android']).contains(s) })
Or also as: row('species').setIntersection(['Saiyan', 'Human', 'Android']).isEmpty().not()
The succintness of ReQL depends on that of the host language. JavaScript's bulky syntax for functions and lack of operator overloading make queries a lot more cluttered.
Pursuing this a little further then, suppose you wanted to expand your search to include humans and androids. In SQL, only a slight modification is needed:
I shudder to think what that would look like in functional form. Something like this? But how would it know how to group the disjunctions?In my very limited experience, examples like these always look so tantalizing until you start taking them a little further and then you quickly realize there's no such thing as a free lunch. In this case, you pay for the flexibility of RethinkDB with the expressiveness SQL.