Skip to content
Stardog JavaScript Framework for node.js and the browser - Develop apps using the Stardog RDF Database & JS.
JavaScript HTML Other
Find file
Latest commit 9e3a357 Edgar Rodriguez Add/Update test cases
- Add test case for query with property paths
- Update test results based on latest changes in stardog 4.0.3
Failed to load latest commit information.
data Add/Update test cases
examples * adding example of usage in browser
js Bump up version to v0.3.1
scripts
test
.gitignore Merge pullrequest/25 + test case to createDB
.jshintrc Linting JS code & some style to html test runner
.npmignore Verifying the ignored files for bower & node installations
CHANGELOG.md Bump up version to v0.3.1
CONTRIBUTING.md Adding missing point in CONTRIBUTING.md
COPYING starting repo clean with version 0.0.1 for community dev
LICENSE * revert copyright
README.md Bump up version to v0.3.1
bower.json Bump up version to v0.3.1
load_test_data.bat * adding missin exportDB call
load_test_data.sh * adding missin exportDB call
package.json Bump up version to v0.3.1
test.js Using win-spawn to have a platform independent test script, tested to…

README.md

Stardog.js

Gitter

Licensed under the Apache License, Version 2.0
Current Version 0.3.1

Stardog.js JavaScript Framework for node.js to develop apps with the Stardog RDF Database.

For detailed documentation, see the annotated source.

What is it?

This framework wraps all the functionality of a client for the Stardog DBMS, and provides access to a full set of functions such as executing SPARQL Queries, administration tasks on Stardog, and the use of the Reasoning API.

All the implementation uses the HTTP protocol, since most of Stardog functionality is available using this protocol. For more information, go to the Stardog's HTTP Programming documentation.

The framework is currently supported for node.js and the browser, including test cases for both environments. You'll also need npm and bower to run the test cases and install the dependencies in node.js & the browser respectively.

Installation

To install stardog.js locally from the npm registry simply execute:

In node.js

npm install stardog

That will fetch the latest version of stardog.js in the npm registry, more details.

In the browser (client library using bower)

bower install stardog

That will fetch the latest version of stardog.js in the bower registry, more details.

Development

To get started, just clone the project. You'll need a local copy of Stardog to be able to run the tests. For more information on starting the Stardog DB service and how it works, go to Stardog's documentation, where you'll find everything you need to get up and running with Stardog.

Go to http://stardog.com, download and install the database and load the data provided in data/ using the script in the repository.

  1. Start the Stardog server

    • Stardog > 2.1.1

      $ stardog-admin server start
      
    • Stardog <= 2.1.1

      $ stardog-admin server start --port 5823
      
  2. Install stardog.js dependencies:

    $ npm install
    $ bower install
    

This will install all the dependencies using npm (for node.js) and bower (for browser), once this is done, run the test cases.

Running Tests

Run all the test cases in test/spec, all test cases must pass. Having the Stardog server running, execute the following commands:

  • In the browser

    1. Load the test data using the provided script:

      $ ./load_test_data.sh
      
    2. Run the test cases

      • Stardog > 2.1.1

        $ open test/index.html
        
      • Stardog <= 2.1.1

        $ node test/testCORS.js
        $ open test/index.html
        
  • In node.js

    $ npm test
    

Version details

Stardog.js depends of the Stardog HTTP API, and any change in this API will be supported by Stardog.js. Here's a list of version compatibility between Stardog and Stardog.js:

Stardog Version Stardog.js Version
<= 1.1.5 <= 0.0.3
1.2 - 2.0.0 0.0.4, 0.0.5
2.0.0 >= 0.1.0

Quick Example

node.js

var stardog = require("stardog");

var conn = new stardog.Connection();

conn.setEndpoint("http://myserver:myport/");
conn.setCredentials("username", "password");

conn.query({
        database: "myDB",
        query: "select distinct ?s where { ?s ?p ?o }",  
        limit: 10,
        offset: 0
    },
    function (data) {
        console.log(data.results.bindings);
});

Browser

NOTE: the Endpoint is a proxy to the Stardog HTTP interface in order to avoid CORS issues (an example can be fount in test/testCORS.js.

<script src="js/stardog.js" type="text/javascript"></script>
…
<script type="text/javascript">
    var conn = new Stardog.Connection();
    conn.setEndpoint("/stardog");
    conn.setReasoning(true);
    conn.setCredentials("browser", "secret");
</script>

NOTE

This framework is in continuous development, please check the issues page. You're welcome to contribute.

   

Something went wrong with that request. Please try again.