RethinkDB(使用ReQL 為query language)
brew update && brew install rethinkdb
r = require('rethinkdb');
var connection = null;
r.connect( {host: 'localhost', port: 28015}, function(err, conn) {
if (err) throw err;
connection = conn;
console.log(conn);
})
r = require('rethinkdb');
r.connect( {host: 'localhost', port: 28015}, function(err, connection) {
if (err) throw err;
r.db('test').tableCreate('authors').run(connection, function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));
});
});
r = require('rethinkdb');
r.connect( {host: 'localhost', port: 28015}, function(err, connection) {
if (err) throw err;
r.table('authors').run(connection, function(err, cursor) {
if (err) throw err;
cursor.toArray(function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));
});
});
});
r = require('rethinkdb');
r.connect( {host: 'localhost', port: 28015}, function(err, connection) {
if (err) throw err;
r.table('authors').changes().run(connection, function(err, cursor) {
if (err) throw err;
cursor.each(function(err, row) {
if (err) throw err;
console.log(JSON.stringify(row, null, 2));
});
});
});
r = require('rethinkdb');
r.connect( {host: 'localhost', port: 28015}, function(err, connection) {
if (err) throw err;
r.table('authors').update({type: "fictional"}).
run(connection, function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));
});
});