@tpluscode/fun-ddr-sparql-graph-repository
TypeScript icon, indicating that this package has built-in type declarations

0.4.1 • Public • Published

SPARQL Graph Store for fun-ddr

Installation

npm i --save @tpluscode/fun-ddr-sparql-graph-repository hydra-box

Usage

  1. Create a repository
import rdfFetch from 'hydra-box/lib/rdfFetch'
import { SparqlGraphRepository } from '@tpluscode/fun-ddr-sparql-graph-repository'
import { expand } from '@zazuko/rdf-vocabularies'

const sparqlClient = new SparqlHttp({
  endpointUrl,
  updateUrl,
  fetch: rdfFetch,
})

// The namespace URI for resources
const base = 'http://my.resource.ns/'

// JSON-LD context document for (de)serializing
const context = {
  '@vocab': 'https://my.vocabulary.ns/',
  name: expand('schema:name'),
}

// A frame used to deserialize triples
const frame  = {
  '@type': 'Person',
}

export const people = new SparqlGraphRepository<T>(sparqlClient, base, context, frame)
  1. Use it to retrieve and save aggregates
import { people } from './repository/people'

const person = await people.load('...')

person.mutate(changeLastName)({ newName: 'Doe', reason: 'marriage' })
  .commit(people)
  .catch(console.error)

Readme

Keywords

Package Sidebar

Install

npm i @tpluscode/fun-ddr-sparql-graph-repository

Weekly Downloads

0

Version

0.4.1

License

MIT

Unpacked Size

16.3 kB

Total Files

5

Last publish

Collaborators

  • tpluscode