store-api
A library making it easier to work with different triplestores by providing a unified interface for common admin and user actions.
Supported stores:
Documentation
Common Interface
async createDb (dbname, options)
GraphDB, Fuseki, Stardogasync dropDb (dbname, options)
GraphDB, Fuseki, Stardogasync clearDb (dbname, options)
GraphDB, Fuseki, Stardogasync online (dbname, options)
Fuseki, Stardogasync offline (dbname, options)
Fuseki, Stardogasync ask (dbname, sparql, options)
GraphDB, Fuseki, Stardogasync construct (dbname, sparql, options)
GraphDB, Fuseki, Stardogasync describe (dbname, sparql, options)
GraphDB, Fuseki, Stardogasync select (dbname, sparql, options)
GraphDB, Fuseki, Stardogasync update (dbname, sparql, options)
GraphDB, Fuseki, Stardogasync import (dbname, ntriples, graph)
GraphDB, Fuseki, Stardog
Usage
import { Fuseki, GraphDB, Stardog } from 'store-api'
const dbname = 'test'
const db = new Fuseki({ user: '…', password: '…', endpoint: 'http://…' }) // or GraphDB or Stardog
await db.createDb(dbname)
await db.import(dbname, fs.readFileSync('./triples.nt'))
const count = await db.select(dbname, 'select (count(*) as ?tot) where { ?s ?p ?o. }')
const inserted = Number(count.results.bindings[0].tot.value)
console.log({ inserted })
await db.clearDb(dbname)
await db.dropDb(dbname)
The tests create, drop, clear DBs, import data and query data, they can also be used as usage reference.
Store Specific
User Management & Permissions
Fuseki
Not supported
GraphDB
Documentation: https://ontotext-ad.github.io/graphdb.js/GraphDBServerClient.html
import { GraphDB } from 'store-api'
const db = new GraphDB({ user: '…', password: '…', endpoint: 'http://…' })
db.conn.getUser(username)
Stardog
Documentation: https://github.com/stardog-union/stardog.js/tree/065edf84d92f50dc6ad9a6548d0bc9b16325cd3d#user
import { Stardog } from 'store-api'
import stardogLib from 'stardog'
const { user } = stardogLib
const db = new Stardog({ user: '…', password: '…', endpoint: 'http://…' })
user.get(db.conn, username, params)