Node tarantool driver for 1.6
JavaScript Lua


Build Status

Node tarantool driver for 1.6 support Node.js v.0.12+ and IO.js.

Based on and implements, for more information you can read them or basic documentation at

For work with tarantool tuple i use msgpack-lite and array default transformation with this package.

If you have a problem with connection it will be destroyed. You can subscribe on TarantoolConnection.socket.on('close') for retrieve information about closing connection or you can process rejected errors for you requests.


npm install --save tarantool-driver

Usage example

We use TarantoolConnection instance and connect before other operations. Methods call return promise( Available methods with some testing: select, update, replace, insert, delete, auth, destroy.

var TarantoolConnection = require('tarantool-driver');
var conn = new TarantoolConnection({port: 3301});
  //auth for login, password
  return conn.auth('test', 'test');
  // select arguments space_id, index_id, limit, offset, iterator, key
  return, 0, 1, 0, 'eq', [50]);

Msgpack implentation

You can use any implementation that can be duck typing with next interface:

//msgpack implementation example
    decode: (Buffer buf)
    encode: (Object obj)
var exampleCustomMsgpack = {
    encode: function(obj){
        return yourmsgpack.encode(obj);
    decode: function(buf){
        return yourmsgpack.decode(obj);

By default use msgpack-lite package.


class TarantoolConnection(options)

var defaultOptions = {
    host: 'localhost',
    port: '3301',
    log: false,
      msgpack: require('msgpack-lite'),
    timeout: 3000

You can overrid default options with options.

connect() : Promise

Resolve if connected. Or reject if not.

auth(login: String, password: String) : Promise

Auth with using chap-sha1( About authenthication more here:

select(spaceId: Number or String, indexId: Number or String, limit: Number, offset: Number, iterator: Iterator, key: tuple) : Promise( Array of tuples)

Iterators: Available iterators: 'eq', 'req', 'all', 'lt', 'le', 'ge', 'gt', 'bitsAllSet', 'bitsAnySet', 'bitsAllNotSet'.

It's just select. Promise resolve array of tuples.

Some examples:, 0, 1, 0, 'eq', [50]);
//same as'test', 'primary', 1, 0, 'eq', [50]);

You can use space name or index name instead if id but it will some requests for get this metadata. That information actual for delete, replace, insert, update too.

delete(spaceId: Number or String, indexId: Number or String, key: tuple) : Promise(Array of tuples)

Promise resolve an array of deleted tuples.

update(spaceId: Number or String, indexId: Number or String, key: tuple, ops) : Promise(Array of tuples)

Ops: (search for update here).

Promise resolve an array of updated tuples.

insert(spaceId: Number or String, tuple: tuple) : Promise(Tuple)

So it's insert. More you can read here:

Promise resolve a new tuple.

upsert(spaceId: Number or String, ops: array of operations, tuple: tuple) : Promise()

About operation:

Ops: (search for update here).

Promise resolve nothing.

replace(spaceId: Number or String, tuple: tuple) : Promise(Tuple)

So it's replace. More you can read here:

Promise resolve a new or replaced tuple.

call(functionName: String, args...) : Promise(Array or undefined)

Call function with arguments. You can find example at test.

You can create function on tarantool side:

function myget(id)
    val ={id}
    return val[1]

And then use something like this:'myget', 4)

If you have a 2 arguments function just send a second arguments in this way:'my2argumentsfunc', 'first', 'second arguments')

And etc like this.

Because lua support a multiple return it's always return array or undefined.

destroy(interupt: Boolean) : Promise

If you call destroy with interupt true it will interupt all process and destroy socket connection without awaiting results. Else it's stub methods with promise reject for future call and await all results and then destroy connection.


Now it's poor test just a win to win situation and some hacks before. Install all packages and tarantool on your machine then launch a test through:

$ ./test/box.lua

Then just a use npm test and it will use mocha and launch test.


It's ok you can do whatever you need. I add log options for some technical information it can be help for you. If i don't answer i just miss email :( it's a lot emails from github so please write me to directly if i don't answer in one day.



Fix test for call changes and remove unuse upsert parameter (critical change API for upsert)


Add clear schema cache on change schema id


Change msgpack5 to msgpack-lite(thx to @arusakov).
Add msgpack as option for connection.
Bump msgpack5 for work at new version.


Add upsert operation.
Key is now can be just a number.


Test eval methods and make benchmarks and improve performance.