Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
rethinkdbdash
Advanced tools
A Node.js driver for RethinkDB with promises and a connection pool.
This is the branch stable
for the last stable version of Node (currently 0.10.26
).
The tests for this branch are ridiculously few. The main tests are run with Node 0.11.10
.
Example wih express:
var app = require('express')();
var r = require('rethinkdbdash')();
app.use(function(req, res, next){
r.table("foo").get("bar").run().then(function(result) {
this.body = JSON.stringify(result);
}).error(function(error) {
res.status(500);
res.render('error', { error: error });
});
})
app.listen(3000);
libprotobuf
binary and development files (required to build node-protobuf
in the next step).npm
.npm install rethinkdbdash
While rethinkdbdash uses almost the same syntax as the official driver, there are still a few differences.
This section references all the differences. For all the other methods not mentionned here, please refer to the official driver's documentation.
The differences are:
Import rethinkdbdash:
var r = require('rethinkdbdash')(options);
options
can be:
{pool: false}
-- if you do not want to use a connection pool.{
min: <number>, // minimum number of connections in the pool, default 50
max: <number>, // maximum number of connections in the pool, default 1000
bufferSize: <number>, // minimum number of connections available in the pool, default 50
timeoutError: <number>, // wait time before reconnecting in case of an error (in ms), default 1000
timeoutGb: <number>, // how long the pool keep a connection that hasn't been used (in ms), default 60*60*1000
}
Rethinkdbdash returns a bluebird promise when a method in the official driver takes a callback.
Example:
r.table("foo").run().then(function(connection) {
//...
}).error(function(e) {
console.log(e.mssage)
})
Rethinkdbdash implements a connection pool and is created by default.
If you do not want to use a connection pool, iniitialize rethinkdbdash with {pool: false}
like that:
var r = require('rethinkdbdash')({pool: false});
You can provide options for the connection pool with the following syntax:
var r = require('rethinkdbdash')({
min: <number>, // minimum number of connections in the pool, default 50
max: <number>, // maximum number of connections in the pool, default 1000
bufferSize: <number>, // minimum number of connections available in the pool, default 50
timeoutError: <number>, // wait time before reconnecting in case of an error (in ms), default 1000
timeoutGb: <number>, // how long the pool keep a connection that hasn't been used (in ms), default 60*60*1000
});
r.table("foo").run().then(function(cursor) {
// The connection used in the cursor will be released when all the data will be retrieved
cursor.toArray().then(function(result) {
// process(result);
})
})
Get the number of connections
r.getPool().getLength();
Get the number of available connections
r.getPool().getAvailableLength();
Drain the pool
r.getPool().drain();
Note: If a query returns a cursor, the connection will not be released as long as the cursor hasn't fetched everything or has been closed.
Rethinkdbdash does not extend Array
with methods and returns a cursor as long as your
result is a sequence.
r.expr([1, 2, 3]).run().then(function(cursor) {
console.log(JSON.stringify(cursor)) // does *not* print [1, 2, 3]
cursor.toArray().then(function(result) {
console.log(JSON.stringify(result)) // print [1, 2, 3]
})
})
Long backtraces are split on multiple lines.
In case the driver cannot parse the query, it provides a better location of the error.
In case an error occured because the server cannot parse the protobuf message, the
official driver emits an error
on the connection.
Rethinkdbdash emits an error and rejects all queries running on this connection and
close the connection. This is the only way now to avoid having some part of your
program hang forever.
The maximum nesting depth is your documents is by default 100 (instead of 20). You can change this setting with
r.setNestingLevel(<number>)
The tree representation of the query is built step by step and stored which avoid
recomputing it if the query is re-run.
exprJSON
, internal method used by insert
, is more efficient in the worst case.
If you do not wish to use rethinkdbdash connection pool, you can implement yours. The connections created with rethinkdbdash emits a "release" event when they receive an error, an atom, or the end (or full) sequence.
A connection can also emit a "timeout" event if the underlying connection times out.
Update test/config.js
if your RethinkDB instance doesn't run on the default parameters.
Run
npm test
Tests are also being run on wercker:
============
FAQs
A Node.js driver for RethinkDB with promises and a connection pool
The npm package rethinkdbdash receives a total of 8,175 weekly downloads. As such, rethinkdbdash popularity was classified as popular.
We found that rethinkdbdash demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.