Book Image

Mastering RethinkDB

By : Shaikh
Book Image

Mastering RethinkDB

By: Shaikh

Overview of this book

RethinkDB has a lot of cool things to be excited about: ReQL (its readable,highly-functional syntax), cluster management, primitives for 21st century applications, and change-feeds. This book starts with a brief overview of the RethinkDB architecture and data modeling, and coverage of the advanced ReQL queries to work with JSON documents. Then, you will quickly jump to implementing these concepts in real-world scenarios, by building real-time applications on polling, data synchronization, share market, and the geospatial domain using RethinkDB and Node.js. You will also see how to tweak RethinkDB's capabilities to ensure faster data processing by exploring the sharding and replication techniques in depth. Then, we will take you through the more advanced administration tasks as well as show you the various deployment techniques using PaaS, Docker, and Compose. By the time you have finished reading this book, you would have taken your knowledge of RethinkDB to the next level, and will be able to use the concepts in RethinkDB to develop efficient, real-time applications with ease.
Table of Contents (11 chapters)

Developing a proof-of-concept application with MongoDB and MySQL


Till now, we have learned about Polyglot Persistence and why RethinkDB is best suited for it. It's time to get to work and prove that this kind of system can be implemented with RethinkDB. In this section, we are going to develop an application that will use three databases, RethinkDB, MySQL, and MongoDB, where RethinkDB will act as an entry database.

We will develop an application where you can perform the CRUD operation in RethinkDB and all changed data will be synchronized automatically to MySQL and MongoDB.

Consider the following diagram:

As you can see in the preceding diagram, the server will first perform the data manipulation in RethinkDB and by using the changefeed we will notify and update MongoDB and MySQL.

Before moving ahead to the code part, let's do some quick data modeling for all three databases. We are going to store personal data related to the users. Here is the simple data model schema for RethinkDB:

{ 
 ...