basex - A BaseX client for node.js
===========================
This is a BaseX client for Node.js. It is work in progress. It uses the client interface via a socket connection to the BaseX server.
BaseX is a very light-weight, high-performance and scalable XML Database engine and XPath/XQuery 3.0 Processor, including full support for the W3C Update and Full Text extensions. Built as a lightweight Java server, BaseX also supports XSLT, Webdav and RestXQ.
Installing the BaseX Node client
To install with npm:
npm install basex
$ mkdir myproject
cd myproject
$ npm install basex
basex@0.9.0 ./node_modules/basex
Once BaseX is installed and the BaseX server is running, test it.
$ cd examples/
$ node Example.js
milliseconds: 0
{ result: '1 2 3 4 5 6 7 8 9 10',
info: '\nQuery executed in 0.38 ms.\n' }
end
close
Installing BaseX
- Java is required
- Download and install BaseX (tested against version 8.6)
- Run
basexserver -S
API specification
See commands.md in the docs folder for details of the API.
Tests
There is a test suite using mocha , should and sinon.
mocha -R spec test/
Execute info command
✓ should not error
✓ should have reply
Send an valid xquery statement: 2+2
✓ It should not error
✓ It should equal 4
Send an invalid command: 2+
✓ It should error
Create a database
✓ It should not error
Add a document
✓ It should not error
drop db database
✓ It should not error
drop db database
✓ It should not error
Send a xquery and iterate over the result items
✓ It should not error
✓ It should return an array
create query and bind
✓ It should not error
✓ It should return a string
13 tests complete (408 ms)
Tools
Javascript is formated using js-beautify js-beautify -r index.js
Documentation is generated using jsdoc -r -d docs --verbose index.js
Contributing
Anyone is welcome to submit issues and pull requests
Thanks to:
Todo
- stream i/o
- reconnect
Alternative clients
- https://github.com/alxarch/basex-stream
- https://github.com/nerdenough/node-basex
- https://github.com/hanshuebner/simple-basex
Inspiration
Parts inspired by node_redis, BaseX Java client
License
BSD license