ReQL queries are chainable
Almost all ReQL queries are chainable. You can chain ReQL queries using the dot
operator, just like you do with pipe in Unix. Data flows from left to right and data from one command is passed to the next one until the query gets executed. You can chain queries until your query is done.
Just like we performed some queries on the previous section, we chained the get()
function with update()
or delete()
to perform the query.
Here is an example:
rethinkdb.table('users').delete(); rethinkdb.table('users').get('<<id>>').update({id : 10}); rethinkdb.db('test').table('users').distinct().count();
This way of design provides a natural way of reading and understanding queries. It's easy to learn, modify, and read.