Skip to content

Latest commit

 

History

History
65 lines (52 loc) · 2.15 KB

File metadata and controls

65 lines (52 loc) · 2.15 KB

Using quadstore in browsers

This project serves as a reference for developers looking to use quadstore in web browsers.

The webpack.config.js file contains the reference configuration for Webpack 5.x that is used to transform dist/bundle.js (initially produced by the TypeScript compiler) into an actual bundle ready for use in browsers as an ES module.

The bundle contains quadstore, the quadstore-comunica SPARQL query engine, the browser-level backend for persistent storage via IndexedDB and rdf-data-factory, an implementation of the RDF/JS DataFactory interface.

package version
quadstore 15.4.1
quadstore-comunica 6.3.1
browser-level 3.0.0
rdf-data-factory 2.0.2

The static/index.html page and associated dist/main.js script provide a small demonstration of how to use all of the above.

The bundle file is also served at https://cdn.jsdelivr.net/gh/quadstorejs/quadstore-browser/dist/bundle.js and can be used in webpages as follows:

<script type="module">
    import {
        Quadstore,
        Engine,
        BrowserLevel,
        DataFactory,
    } from 'https://cdn.jsdelivr.net/gh/quadstorejs/quadstore-browser/dist/bundle.js';
    const backend = new BrowserLevel('quadstore');
    const dataFactory = new DataFactory();
    const store = new Quadstore({ backend, dataFactory });
    const engine = new Engine(store);
    await store.open();
    await store.clear();
    await store.put(dataFactory.quad(dataFactory.namedNode('ex://s'), dataFactory.namedNode('ex://p'), dataFactory.namedNode('ex://o')));
    const stream = await engine.queryBindings(`SELECT * WHERE { ?s ?p ?o }`);
    stream.on('data', console.log);
</script>

How to build

npm install
npm run build

Issues

Issues should be reported in quadstore's issue tracker.