Skip to content

Instantly share code, notes, and snippets.

@srh
Created March 21, 2013 09:55
Show Gist options
  • Save srh/5211904 to your computer and use it in GitHub Desktop.
Save srh/5211904 to your computer and use it in GitHub Desktop.
rethinkdb chain insert docs
var r = require('rethinkdb');
var doc = {
type: 'user',
username: 'test_user_1',
firstName: 'one',
lastName: 'uno',
emailAddress: 'one@test.com',
roles: ['user']
}
r.connect({host: 'localhost', port: 28015 }, function(err, conn) {
function chain_inserts() {
r.db('test').table('users').insert(doc).run(conn, function(err, result) {
if(err) {
throw err;
}
console.log(result.generated_keys);
chain_inserts();
});
}
chain_inserts();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment