Skip to main content

Running Queries across multiple tables in RethinkDB

Recently i was building a microservice which has RethinkDB used. Its a great choice if you are looking to quickly build a realtime service. The service i built had a new table for each user account, while testing i had added some records with missing keys. Obviously it would be hard to remove them and add again for each table, so i used this snippet to update each record in all of the tables -

    .do(tables => tables.forEach(name => r.db("test_db").table(name)
        .update({ visits: "3" })));
The above query will find all of the available tables, loop on them and on each record it will update the visits to 3, Just like this you can use filter, delete and other methods across multiple tables.

Hope this helps!