Skip to content

Commit 335b242

Browse files
committed
Update for call and remove vow to native Promise
1 parent 1749603 commit 335b242

File tree

5 files changed

+308
-158
lines changed

5 files changed

+308
-158
lines changed

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# node-tarantool-driver
2-
Node tarantool driver for 1.6 support Node.js v.0.10+ and IO.js.
2+
Node tarantool driver for 1.6 support Node.js v.0.12+ and IO.js.
33

44
Based on https://github.com/mialinx/go-tarantool-1.6 and implements http://tarantool.org/doc/dev_guide/box-protocol.html, for more information you can read them or basic documentation at http://tarantool.org/doc/.
55

@@ -15,7 +15,7 @@ npm install --save tarantool-driver
1515

1616
##Usage example
1717

18-
We use TarantoolConnection instance and connect before other operations. Methods call return promise(through vow(https://github.com/dfilatov/vow). Available methods with some testing: select, update, replace, insert, delete, auth, destroy.
18+
We use TarantoolConnection instance and connect before other operations. Methods call return promise(https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Promise). Available methods with some testing: select, update, replace, insert, delete, auth, destroy.
1919
```
2020
var TarantoolConnection = require('tarantool-driver');
2121
var conn = new TarantoolConnection({port: 3301});
@@ -80,6 +80,34 @@ So it's replace. More you can read here: http://tarantool.org/doc/book/box/box_s
8080

8181
Promise resolve a new or replaced tuple.
8282

83+
**call(functionName: String, args...) : Promise(Array or undefined)**
84+
85+
Call function with arguments. You can find example at test.
86+
87+
You can create function on tarantool side:
88+
```
89+
function myget(id)
90+
val = box.space.batched:select{id}
91+
return val[1]
92+
end
93+
```
94+
95+
And then use something like this:
96+
```
97+
conn.call('myget', 4)
98+
.then(function(value){
99+
console.log(value);
100+
});
101+
```
102+
103+
If you have a 2 arguments function just send a second arguments in this way:
104+
```
105+
conn.call('my2argumentsfunc', 'first', 'second arguments')
106+
```
107+
And etc like this.
108+
109+
Because lua support a multiple return it's always return array or undefined.
110+
83111
**destroy(interupt: Boolean) : Promise**
84112

85113
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.
@@ -91,12 +119,12 @@ Now it's poor test just a win to win situation and some hacks before. Install al
91119
$ ./test/box.lua
92120
```
93121

94-
Then just a use **npm start** and it will use mocha and launch test.
122+
Then just a use **npm test** and it will use mocha and launch test.
95123

96124
##Contributions
97125

98126
It's ok you can do whatever you need.
99127

100128
##ToDo
101129

102-
Test **eval** and **call** methods.
130+
Test **eval** methods.

0 commit comments

Comments
 (0)