Skip to content

Commit 92d5a76

Browse files
committed
Create README.md
1 parent 41865bf commit 92d5a76

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# node-tarantool-driver
2+
Node tarantool driver for 1.6 support Node.js v.0.10+ and IO.js.
3+
4+
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/.
5+
6+
For work with tarantool tuple i use node-msgpack(https://github.com/pgriess/node-msgpack) and array default transformation with this package.
7+
8+
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.
9+
10+
##Install
11+
12+
```
13+
npm install --save tarantool-driver
14+
```
15+
16+
##Usage example
17+
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.
19+
```
20+
var TarantoolConnection = require('tarantool-driver');
21+
var conn = new TarantoolConnection({port: 3301});
22+
conn.connect()
23+
.then(function(){
24+
//auth for login, password
25+
return conn.auth('test', 'test');
26+
}).then(function(){
27+
// select arguments space_id, index_id, limit, offset, iterator, key
28+
return conn.select(512, 0, 1, 0, 'eq', [50]);
29+
})
30+
.then(funtion(results){
31+
doSomeThingWithResults(results);
32+
});
33+
```
34+
35+
##API
36+
37+
**class TarantoolConnection(options)**
38+
```
39+
var defaultOptions = {
40+
host: 'localhost',
41+
port: '3301'
42+
};
43+
```
44+
You can overrid default options with options.
45+
46+
**connect() : Promise**
47+
48+
Resolve if connected. Or reject if not.
49+
50+
**auth(login: String, password: String) : Promise **
51+
52+
Auth with using chap-sha1(http://tarantool.org/doc/book/box/box_space.html). About authenthication more here: http://tarantool.org/doc/book/box/authentication.html
53+
54+
**select(spaceId: Number, indexId: Number, limit: Number, iterator: Iterator, key: tuple) : Promise( Array of tuples)**
55+
56+
Iterators: http://tarantool.org/doc/book/box/box_index.html
57+
```
58+
const IteratorsType = {
59+
eq: 0,
60+
req: 1,
61+
all: 2,
62+
lt: 3,
63+
le: 4,
64+
ge: 5,
65+
gt: 6,
66+
bitsAllSet: 7,
67+
bitsAnySet: 8,
68+
bitsAllNotSet: 9
69+
};
70+
```
71+
It's just select. Promise resolve array of tuples.
72+
73+
**delete(spaceId: Number, indexId: Number, key: tuple) : Promise(Array of tuples) **
74+
75+
Promise resolve an array of deleted tuples.
76+
77+
**update(spaceId: Number, indexId: Number, key: tuple, ops) : Promise(Array of tuples)**
78+
79+
Ops: http://tarantool.org/doc/book/box/box_space.html(search for update here).
80+
81+
Promise resolve an array of updated tuples.
82+
83+
**insert(spaceId: Number, tuple: tuple) : Promise(Tuple) **
84+
85+
So it's insert. More you can read here: http://tarantool.org/doc/book/box/box_space.html
86+
87+
Promise resolve a new tuple.
88+
89+
90+
**replace(spaceId: Number, tuple: tuple) : Promise(Tuple) **
91+
92+
So it's replace. More you can read here: http://tarantool.org/doc/book/box/box_space.html
93+
94+
Promise resolve a new or replaced tuple.

0 commit comments

Comments
 (0)