Inserting data

Before inserting documents into the database, we must create a table to hold our data. We can do this using the tableCreate() command that takes the table name as an argument. Let's create a table called people by running the following query:

r.db('test').tableCreate('people')

This query assumes you have a database called test and creates the people table within this database. If the query is successful, you will get an output similar to this:

{ "config_changes":[ { "new_val":{ "db":"test", "durability":"hard", "id":"a29447ca-1587-4b8c-86db-a7b3d5198519", "name":"people", "primary_key":"id", "shards":[ { "primary_replica":"rethinkdb1", "replicas":[ "rethinkdb1" ] } ], "write_acks":"majority" }, "old_val":null } ], "tables_created":1 ...

Get Getting Started with RethinkDB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.