- Install RethinkDB
- Download sources from github or with npm
npm install rethink-driver
- Run
npm install
in rethink-driver directory
If you don't provide the connection details, the default details will be used.
var RethinkDB = require('rethink-driver');
var db = new RethinkDB(host, port, dbName);
db.connect(connectedCallback);
function connectedCallback(conn) {
// ...
}
var query = db.QueryFactory.Find.create('test_table');
db.executeQuery(query).then(function (result) {
if (result.hasError()) {
console.log(result.getError());
return;
}
result.getResultSet().cursor...;
});
db.allowToArrayConversation();
You can access the items from the cursor as an array:
for (result.getResultSet().getList() as item) {
// ...
}
In some cases it could be totally not useful. That it the reason, why its false by default.
Create a database named rethink_db_test
first.
nodejs tests -log=4