Skip to main content

TripleStore

This service allows you to interface with a Jena Fuseki triple store.

Features#

  • Basic triple store operations
    • Query
    • Update
    • Insert
    • Delete
  • Basic utilities
    • Count number of triples of a subject
    • Drop all triples in a dataset

Dependencies#

  • None

Install#

$ npm install @semapps/triplestore --save

Usage#

const { TripleStoreService } = require('@semapps/triplestore');
module.exports = {
mixins: [TripleStoreService],
settings: {
sparqlEndpoint: 'http://localhost:3030/',
mainDataset: 'myDataSet',
jenaUser: 'admin',
jenaPassword: 'admin'
}
};

Settings#

PropertyTypeDefaultDescription
sparqlEndpointStringrequiredJena Fuseki's root URI
mainDatasetStringrequiredUsed dataset
jenaUserStringrequiredJena Fuseki's admin login
jenaPasswordStringrequiredJena Fuseki's admin password

Actions#

The following service actions are available:

triplestore.query#

  • Execute a SPARQL Query and return result in accept type provided
  • SELECT, CONSTRUCT, ASK queries are supported
  • Accept triples, turtle or JSON-LD (see @semapps/mime-types package)
Parameters#
PropertyTypeDefaultDescription
queryStringnullSPARQL query to execute
acceptStringrequiredType to return (application/ld+json, text/turtle or application/n-triples)
webIdStringLogged user's webIdUser doing the action
Return#

String or Object depending on accept

triplestore.update#

  • Execute a SPARQL update query
  • DELETE, INSERT queries supported (see specifications)
Parameters#
PropertyTypeDefaultDescription
queryStringnullSPARQL Update to execute
webIdstringLogged user's webIdUser doing the action
Return#

None

triplestore.insert#

  • Insert a list of triples
  • Accept triples, turtle or JSON-LD (see @semapps/mime-types package)
Parameters#
PropertyTypeDefaultDescription
resourceObject, StringrequiredTriples to insert
contentTypeStringtext/turtleType of data provided (application/ld+json, text/turtle or application/n-triples)
webIdStringLogged user's webIdUser doing the action
Return#

None

delete#

  • Delete all triples associated with a subject
Parameters#
PropertyTypeDefaultDescription
uriStringrequiredSubject
webIdStringLogged user's webIdUser doing the action
Return#

None

triplestore.countTripleOfSubject#

  • Count all triples associated with a subject
Parameters#
PropertyTypeDefaultDescription
uriStringrequiredSubject
webIdStringLogged user's webIdUser doing the action
Return#

Integer - Number of triples associated with the given subject

triplestore.dropAll#

  • Delete all triples on the dataset
Parameters#
PropertyTypeDefaultDescription
webIdStringLogged user's webIdUser doing the action
Return#

None