tarantool-driver
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -178,3 +178,3 @@ 'use strict'; | ||
else | ||
dfd.reject(obj[1][tarantoolConstants.KeysCode.error]); | ||
dfd.reject(new Error(obj[1][tarantoolConstants.KeysCode.error])); | ||
if (this.awaitingDestroy && this.commandsQueue.length == 1) | ||
@@ -196,3 +196,3 @@ { | ||
TarantoolConnection.prototype.onError = function(error){ | ||
this._interupt(); | ||
this._interupt(error); | ||
this._stubMethods(); | ||
@@ -227,3 +227,3 @@ this.socket.destroy(); | ||
{ | ||
reject(this.awaitingDestroy ? 'already destroyed' : 'already connected'); | ||
reject(new Error(this.awaitingDestroy ? 'already destroyed' : 'already connected')); | ||
if (this.options.log) | ||
@@ -276,14 +276,19 @@ { | ||
return new Promise(function (resolve, reject) { | ||
var reqId = requestId.getId(); | ||
var header = this._header(tarantoolConstants.RequestCode.rqDelete, reqId); | ||
var buffered = { | ||
spaceId: msgpack.encode(spaceId), | ||
indexId: msgpack.encode(indexId), | ||
key: msgpack.encode(key) | ||
}; | ||
var body = Buffer.concat([new Buffer([0x86,tarantoolConstants.KeysCode.space_id]), buffered.spaceId, | ||
new Buffer([tarantoolConstants.KeysCode.index_id]), buffered.indexId, | ||
new Buffer([tarantoolConstants.KeysCode.key]), buffered.key]); | ||
this._request(header, body); | ||
this.commandsQueue.push([tarantoolConstants.RequestCode.rqSelect, reqId, {resolve: resolve, reject: reject}]); | ||
if (Array.isArray(key)) | ||
{ | ||
var reqId = requestId.getId(); | ||
var header = this._header(tarantoolConstants.RequestCode.rqDelete, reqId); | ||
var buffered = { | ||
spaceId: msgpack.encode(spaceId), | ||
indexId: msgpack.encode(indexId), | ||
key: msgpack.encode(key) | ||
}; | ||
var body = Buffer.concat([new Buffer([0x86,tarantoolConstants.KeysCode.space_id]), buffered.spaceId, | ||
new Buffer([tarantoolConstants.KeysCode.index_id]), buffered.indexId, | ||
new Buffer([tarantoolConstants.KeysCode.key]), buffered.key]); | ||
this._request(header, body); | ||
this.commandsQueue.push([tarantoolConstants.RequestCode.rqSelect, reqId, {resolve: resolve, reject: reject}]); | ||
} | ||
else | ||
reject(new Error('need array')); | ||
}.bind(this)); | ||
@@ -294,3 +299,3 @@ }; | ||
return new Promise(function (resolve, reject) { | ||
if (Array.isArray(ops)){ | ||
if (Array.isArray(ops) && Array.isArray(key)){ | ||
var reqId = requestId.getId(); | ||
@@ -333,3 +338,3 @@ var header = this._header(tarantoolConstants.RequestCode.rqUpdate, reqId); | ||
TarantoolConnection.prototype.call = function(functionName){ | ||
var tuple = Array.prototype.slice.call(arguments, 1); | ||
var tuple = arguments.length > 1 ? Array.prototype.slice.call(arguments, 1): []; | ||
return new Promise(function (resolve, reject) { | ||
@@ -421,3 +426,3 @@ var reqId = requestId.getId(); | ||
{ | ||
this._interupt('force destroy socket'); | ||
this._interupt(new Error('force destroy socket')); | ||
this.socket.destroy(); | ||
@@ -447,3 +452,3 @@ resolve(true); | ||
return new Promise(function (resolve, reject) { | ||
reject('connection will be destroyed or already destroyed, create another one'); | ||
reject(new Error('connection will be destroyed or already destroyed, create another one')); | ||
}); | ||
@@ -450,0 +455,0 @@ }; |
{ | ||
"name": "tarantool-driver", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Tarantool driver for 1.6", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -41,3 +41,4 @@ # node-tarantool-driver | ||
host: 'localhost', | ||
port: '3301' | ||
port: '3301', | ||
log: false | ||
}; | ||
@@ -127,3 +128,3 @@ ``` | ||
It's ok you can do whatever you need. | ||
It's ok you can do whatever you need. I add log options for some technical information it can be help for you. | ||
@@ -130,0 +131,0 @@ ##ToDo |
@@ -40,2 +40,5 @@ /** | ||
.then(function(){ | ||
return conn.call('clearaddmore'); | ||
}) | ||
.then(function(){ | ||
done(); | ||
@@ -104,2 +107,11 @@ }) | ||
}); | ||
it('dup error', function(done){ | ||
conn.insert(512, insertTuple) | ||
.then(function(a){ | ||
done(new Error('can insert')); | ||
}, function(e){ | ||
assert(e instanceof Error); | ||
done(); | ||
}); | ||
}); | ||
it('update', function(done){ | ||
@@ -115,4 +127,4 @@ conn.update(512, 0, [50], [['+',3,10]]) | ||
var promises = []; | ||
for (var i = 0; i <= 1000; i++) { | ||
conn.insert(512, ['key' + i, i]); | ||
for (var i = 0; i <= 5000; i++) { | ||
conn.insert(515, ['key' + i, i]); | ||
} | ||
@@ -119,0 +131,0 @@ Promise.all(promises) |
Sorry, the diff of this file is not supported yet
29914
654
132