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

Updating and deleting documents


Now that you've inserted a few documents into your RethinkDB table, you'll probably be wondering how to update or delete these documents using Node.js.

You'll be happy to know that the queries for updating and removing are exactly the same as the ones you learned in Chapter 2, The ReQL Query Language and used in the web interface. Let's go over them very briefly.

RethinkDB provides us with the update command to update the existing documents. This command accepts as input a JSON document with the required changes. As an example, suppose we want to add a gender field to all documents in the fake_data table. We can do so with the following lines of code:

r.table('fake_data').update({gender: "male"}).run(conn, function(err, result) {
    if (err) throw err;
    console.log(result);
});

As you can see, the query syntax is exactly the same as running it from the web interface. The only difference is appending the run command at the end of the query.

Now, let's take look...

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}