Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Getting Started with RethinkDB

You're reading from  Getting Started with RethinkDB

Product type Book
Published in Mar 2016
Publisher Packt
ISBN-13 9781785887604
Pages 176 pages
Edition 1st Edition
Languages
Author (1):
Gianluca Tiepolo Gianluca Tiepolo
Profile icon Gianluca Tiepolo

Table of Contents (15) Chapters

Getting Started with RethinkDB
Credits
About the Author
Acknowledgement
About the Reviewer
www.PacktPub.com
Preface
1. Introducing RethinkDB 2. The ReQL Query Language 3. Clustering, Sharding, and Replication 4. Performance Tuning and Advanced Queries 5. Programming RethinkDB in Node.js 6. RethinkDB Administration and Deployment 7. Developing Real-Time Web Applications Index

Connecting to RethinkDB


Now that we have everything installed, it's time to start interacting with RethinkDB through Node.js. In the following examples, we'll be adding some fake data to a table in our RethinkDB cluster. We'll be running these commands on a server running Ubuntu Linux.

To start, let's look at how to connect to our RethinkDB instance. First, make sure that your database is up and running. If it's not running, you can start RethinkDB by executing the following command from a terminal window:

sudo /etc/init.d/rethinkdb start

This will start the database. Now, let's have a look at the code used to connect to our instance:

r.connect({host: 'localhost', port: 28015 }, function(err, conn) {
    //
});

As you can see, the RethinkDB module provides us with a connect function, which creates a new connection to the database. This function accepts a few parameters, such as the server host and port. Optionally, you can also specify the name of the database and an authentication key (more...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}