Skip to content

Commit 5aae14c

Browse files
committed
fix popByte undefined
1 parent 9cb3d5b commit 5aae14c

10 files changed

Lines changed: 56 additions & 14 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# basex - A BaseX client for node.js
22
===========================
33

4-
This is BaseX client for Node.js. It is work in progress.
4+
This is BaseX client for Node.js. It is work in progress. It uses the client interface via a socket connection to the BaseX server.
55

66
[BaseX](http://basex.org/) is a very light-weight, high-performance and scalable
77
XML Database engine and XPath/XQuery 3.0 Processor,
@@ -37,7 +37,7 @@ Once BaseX is installed and the BaseX server is running, test it.
3737
## Installing BaseX
3838
1. Java is required
3939
1. [Download](http://basex.org/products/download/all-downloads/) and install BaseX
40-
(tested against version 7.5)
40+
(tested against version 7.6)
4141
1. Run `basexserver -S`
4242
4343
## API specification

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v0.6.2 - 2013-07-13
2+
- fix query array result timing issue (#10)
3+
- fix session.create
4+
15
## v0.6.1 - 2013-02-17
26
- fix authorization bug (#8)
37

examples/Example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* This example shows how database commands can be executed.
44
*/
55
var basex = require("../index");
6-
var client = new basex.Session();
6+
var client = new basex.Session("127.0.0.1", 1984, "admin", "admin");
77
basex.debug_mode = false;
88
function print(err, reply) {
99
if (err) {

examples/issue10.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* This example shows how new databases can be created.
3+
*
4+
*/
5+
var basex = require("../index");
6+
var log = require("../debug");
7+
basex.debug_mode = true;
8+
// create session
9+
var client = new basex.Session("localhost", 1984, "admin", "admin");
10+
11+
// create new database
12+
client.execute("create database gumby", log.print);
13+
client.add("people.xml","<people><person>Gumby\nman</person><something>else</something><person>Pokey\nhorse</person></people>",log.print);
14+
// run query on database
15+
16+
var query = client.query("//bad");
17+
query.results(log.print);
18+
// close session
19+
client.close();

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ var Session = function(host, port, username, password) {
199199
};
200200
// Creates a database from an input stream:
201201
this.create = function(name, input, callback) {
202-
self._dbop("\x08" ,path , input,callback)
202+
self._dbop("\x08" ,name , input,callback)
203203
};
204204
// Adds a document to the current database from an input stream:
205205
this.add = function(path, input, callback) {
@@ -213,6 +213,7 @@ var Session = function(host, port, username, password) {
213213
this.store = function(path, input, callback) {
214214
self._dbop("\x0D" ,path , input,callback)
215215
};
216+
//@TODO allow input to be stream, currently just string
216217
this._dbop=function(op,path, input, callback) {
217218
self.send_command({
218219
send : op + path + "\0" + input+"\0",

lib/parser2.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ var parse = function(stream) {
5555
self.data.unshift(s.substring(1))
5656
return {data:s[0]}
5757
}
58-
}else{
59-
var s=self.buffer;
60-
self.buffer=s.substring(1)
61-
return {data:s[0]};
58+
}else if (self.buffer.length) {
59+
var s = self.buffer;
60+
self.buffer = s.substring(1)
61+
return {data: s[0]};
62+
}
63+
else {
64+
return null;
6265
}
6366
};
6467
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{ "name" : "basex",
2-
"version" : "0.6.1",
2+
"version" : "0.6.2",
33
"description" : "A BaseX (XML database) client library",
44
"keywords": ["xml", "xquery", "xslt", "search", "database" ],
55
"author": "Andy Bunce ",

someFile.txt

-26 Bytes
Binary file not shown.

test/test-auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('Authorization failure ', function() {
3737
session.close(function(e, r) {
3838
reply = r;
3939
err = e;
40-
done();
40+
//done();
4141

4242
});
4343

test/test-commands.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ describe('Send an invalid command: 2+', function() {
6060
});
6161
});
6262

63-
describe('Create a database', function() {
63+
describe('Create a database with execute', function() {
6464
var reply, err;
6565
before(function(done) {
66-
session.execute("create db database", function(e, r) {
66+
session.execute("create db testdb", function(e, r) {
6767
reply = r;
6868
err = e;
6969
done();
@@ -93,7 +93,22 @@ describe('Add a document', function() {
9393
describe('drop db database', function() {
9494
var reply, err;
9595
before(function(done) {
96-
session.execute("drop db database", function(e, r) {
96+
session.execute("drop db testdb", function(e, r) {
97+
reply = r;
98+
err = e;
99+
done();
100+
});
101+
});
102+
103+
it('It should not error', function() {
104+
should.not.exist(err);
105+
});
106+
});
107+
108+
describe('create database', function() {
109+
var reply, err;
110+
before(function(done) {
111+
session.create("testdb", "<x>Hello World!</x>", function(e, r) {
97112
reply = r;
98113
err = e;
99114
done();
@@ -108,7 +123,7 @@ describe('drop db database', function() {
108123
describe('drop db database', function() {
109124
var reply, err;
110125
before(function(done) {
111-
session.execute("drop db database", function(e, r) {
126+
session.execute("drop db testdb", function(e, r) {
112127
reply = r;
113128
err = e;
114129
done();

0 commit comments

Comments
 (0)