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

Reading documents


If you've been following along with the previous examples, your database will now have a table called fake_data that contains 100 documents. Now that we've got some data in our database, let's see how we can read data from RethinkDB from a Node.js script.

We've already seen how RethinkDB provides us with the filter command to read data from the database based on a condition. In the previous chapters, you learned to use this command in the web interface to perform read queries on our datasets.

However, sometimes you may want to read all the data from a table without any filtering. To do this, you just need to select the table from which you want to read, and RethinkDB will give you a cursor to access the data. You can then use the cursor to create an array that includes all the results.

This example reads and prints all the documents from the fake_data table:

r.table("fake_data").run(conn, function(err, cursor) {
    if (err) throw err;
    cursor.toArray(function(err, results...
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 $15.99/month. Cancel anytime}