Skip to content

Filesystem based RDF Store that follows the RDF/JS: Stream interfaces specification

License

Notifications You must be signed in to change notification settings

rdf-ext/rdf-store-fs

Repository files navigation

rdf-store-fs

build status npm version

Filesystem based RDF Store that follows the RDF/JS: Stream interfaces specification.

Install

npm install --save rdf-store-fs

Usage

The package provides classes to implement file stores and comes with easy to use default implementations.

FlatMultiFileStore

The FlatMultiFileStore implements a file store that writes each named graph to a separate file in a flat folder structure. It is only possible to use named graphs from the given baseIRI. Reading or writing a graph to a different namespace will cause an error.

It can be imported with the following line of code:

const FlatMultiFileStore = require('rdf-store-fs/FlatMultiFileStore')

The following options are supported:

  • baseIRI: The base IRI for the named graphs as a string.
  • path: The path to the files for the store as a string.

Example

The following example creates a FlatMultiFileStore file store which writes it's files into the example folder. The quads from the input stream are written to the store. As the named graph is the same as the baseIRI, the quads are written to __index.nt.

const rdf = require('@rdfjs/data-model')
const { Readable } = require('readable-stream')
const FlatMultiFileStore = require('rdf-store-fs/FlatMultiFileStore')

const input = Readable({
  objectMode: true,
  read: function () {
    this.push(rdf.quad(
      rdf.namedNode('http://example.org/subject1'),
      rdf.namedNode('http://www.w3.org/2000/01/rdf-schema#label'),
      rdf.literal('this will be written to the file store'),
      rdf.namedNode('http://example.org/')
    ))

    this.push(null)
  }
})

const store = new FlatMultiFileStore({
  baseIRI: 'http://example.org/',
  path: __dirname
})

const event = store.import(input)

event.on('end', () => {
  console.log('triples written to the file store')
})

About

Filesystem based RDF Store that follows the RDF/JS: Stream interfaces specification

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •