basex

A BaseX (XML database) client library

npm install basex
4 downloads in the last week
53 downloads in the last month

basex - A BaseX client for node.js

===========================

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.

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.

NPM NPM

Installing the BaseX Node client

To install with npm:

npm install basex

    $ mkdir myproject
    cd myproject
    $ npm install basex
    basex@0.6.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

  1. Java is required
  2. Download and install BaseX (tested against version 7.7)
  3. 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/test-commands.js 


  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)

Coding

Javascript is formated using js-beautify js-beautify -r index.js Documentation is generated using jsdoc -r -d docs --verbose index.js

TODO

  • stream i/o
  • reconnect

Inspiration

Parts inspired by node_redis, BaseX Java client

license

BSD license

Bitdeli Badge

npm loves you