Book Image

Getting Started with RethinkDB

By : Gianluca Tiepolo
Book Image

Getting Started with RethinkDB

By: Gianluca Tiepolo

Overview of this book

RethinkDB is a high-performance document-oriented database with a unique set of features. This increasingly popular NoSQL database is used to develop real-time web applications and, together with Node.js, it can be used to easily deploy them to the cloud with very little difficulty. Getting Started with RethinkDB is designed to get you working with RethinkDB as quickly as possible. Starting with the installation and configuration process, you will learn how to start importing data into the database and run simple queries using the intuitive ReQL query language. After successfully running a few simple queries, you will be introduced to other topics such as clustering and sharding. You will get to know how to set up a cluster of RethinkDB nodes and spread database load across multiple machines. We will then move on to advanced queries and optimization techniques. You will discover how to work with RethinkDB from a Node.js environment and find out all about deployment techniques. Finally, we’ll finish by working on a fully-fledged example that uses the Node.js framework and advanced features such as Changefeeds to develop a real-time web application.
Table of Contents (15 chapters)
Getting Started with RethinkDB
Credits
About the Author
Acknowledgement
About the Reviewer
www.PacktPub.com
Preface
Index

Documents


Documents are RethinkDB's main data structure. To fully understand and use the database, you need to think in documents. In this chapter, we're going to go through the lifecycle of designing and saving a document in RethinkDB. We'll follow up by reading, aggregating, and querying documents using ReQL. In the previous section, you'll see how RethinkDB can also manipulate and transform query results.

Documents are self-contained units of data. In relational databases, you might have heard the term record to describe something similar. When you insert some information into a database, the data is usually made up of small native types such as integers and strings. Documents are the first level of abstraction over these native types. They give primitive data some structure and logically group it. Additionally, RethinkDB documents support more complex data types such as binary data, dates and times, and arrays.

Suppose we want to store the age of a person in the database. This data might...