Skip to content

Instantly share code, notes, and snippets.

@pascalesdedy
Created June 22, 2020 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pascalesdedy/0e0afc739b860755e41858405abcce9b to your computer and use it in GitHub Desktop.
Save pascalesdedy/0e0afc739b860755e41858405abcce9b to your computer and use it in GitHub Desktop.
r = require('rethinkdb');
var connection = null;
r.connect( {host: 'localhost', port: 28015}, function(err, conn) {
if (err) throw err;
connection = conn;
r.db('test').tableCreate('authors').run(connection, function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));
r.table('authors').insert([
{ name: "William Adama", tv_show: "Battlestar Galactica",
posts: [
{title: "Decommissioning speech", content: "The Cylon War is long over..."},
{title: "We are at war", content: "Moments ago, this ship received word..."},
{title: "The new Earth", content: "The discoveries of the past few days..."}
]
},
{ name: "Laura Roslin", tv_show: "Battlestar Galactica",
posts: [
{title: "The oath of office", content: "I, Laura Roslin, ..."},
{title: "They look like us", content: "The Cylons have the ability..."}
]
},
{ name: "Jean-Luc Picard", tv_show: "Star Trek TNG",
posts: [
{title: "Civil rights", content: "There are some words I've known since..."}
]
}
]).run(connection, function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment