Executing ReQL queries in a cluster
We have our cluster in place running smoothly; let's perform a ReQL query and observe the response. First we will create a new table in the test
database. As we have learned in Chapter 2, RethinkDB Query Language, we need to use the tableCreate()
method to create a new table.
Let's execute a query from the web administrative screen:
r.db("test").tableCreate('clusterTest2')
Here is our response object:
As you may have noticed the highlighted section, primary_replica
is showing that this table is stored at a machine ending with _y7b
, which is my second machine in the cluster. This proves that RethinkDB automatically utilizes the instances in the cluster.
Let's perform an insert
operation on the same table and observe the response. Here is the insert
ReQL query:
r.db("test").table("clusterTest").insert({name : "Shahid", age : 24})
Upon running it, we see that the document has been inserted in the clusterTest
table and RethinkDB returns exactly the same...