Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Comunica query engine support for the LDflex language

License

NotificationsYou must be signed in to change notification settings

LDflex/LDflex-Comunica

Repository files navigation

This library lets you usetheComunica query enginewith theLDflex language.

npm versionbuildCoverage StatusDependency Status

Installation

npm install ldflex @ldflex/comunica

Usage

const{ PathFactory}=require('ldflex');const{default:ComunicaEngine}=require('@ldflex/comunica');const{ namedNode}=require('@rdfjs/data-model');// The JSON-LD context for resolving propertiesconstcontext={"@context":{"@vocab":"http://xmlns.com/foaf/0.1/","friends":"knows",}};// The query engine and its sourceconstqueryEngine=newComunicaEngine('https://ruben.verborgh.org/profile/');// The object that can create new pathsconstpaths=newPathFactory({ context, queryEngine});asyncfunctionshowPerson(person){console.log(`This person is${awaitperson.name}`);console.log(`${awaitperson.givenName} is friends with:`);forawait(constnameofperson.friends.givenName)console.log(`-${name}`);}construben=paths.create({subject:namedNode('https://ruben.verborgh.org/profile/#me'),});showPerson(ruben);

Features

Using a customised ComunicaEngine

This example uses the comunica engine for local file queries.

const{ PathFactory}=require('ldflex');const{default:ComunicaEngine}=require('@ldflex/comunica');const{ namedNode}=require('@rdfjs/data-model');const{newEngine:localFileEngine}=require('@comunica/actor-init-sparql-file');// The JSON-LD context for resolving propertiesconstcontext={"@context":{"@vocab":"http://xmlns.com/foaf/0.1/","friends":"knows",}};// The query engine and its sourceconstqueryEngine=newComunicaEngine(path.join(__dirname,'ruben-verborgh.ttl'),{engine:localFileEngine()});// The object that can create new pathsconstpaths=newPathFactory({ context, queryEngine});asyncfunctionshowPerson(person){console.log(`This person is${awaitperson.name}`);console.log(`${awaitperson.givenName} is friends with:`);forawait(constnameofperson.friends.givenName)console.log(`-${name}`);}construben=paths.create({subject:namedNode('https://ruben.verborgh.org/profile/#me'),});showPerson(ruben);

Adding custom options to the ComunicaEngine

Addcomunica context options which are passed to the Comunica Engine.

const{ PathFactory}=require('ldflex');const{default:ComunicaEngine}=require('@ldflex/comunica');const{ namedNode}=require('@rdfjs/data-model');// The JSON-LD context for resolving propertiesconstcontext={"@context":{"@vocab":"http://xmlns.com/foaf/0.1/","friends":"knows",}};// The query engine and its sourceconstqueryEngine=newComunicaEngine('https://ruben.verborgh.org/profile/',{options:{/* add options here */}},);// The object that can create new pathsconstpaths=newPathFactory({ context, queryEngine});asyncfunctionshowPerson(person){console.log(`This person is${awaitperson.name}`);console.log(`${awaitperson.givenName} is friends with:`);forawait(constnameofperson.friends.givenName)console.log(`-${name}`);}construben=paths.create({subject:namedNode('https://ruben.verborgh.org/profile/#me'),});showPerson(ruben);

Updating data

By default the source given is also used as the destination for updates (if multiple sources are given, then the first one is chosen).

Optionally you can specify your own destination for updates as follows

// The query engine and its sourceconstqueryEngine=newComunicaEngine('https://ruben.verborgh.org/profile/',{destination:'https://example.org/destination'},);

License

©2018–presentRuben Verborgh, Joachim Van Herwegen,Jesse Wright.MIT License.

About

Comunica query engine support for the LDflex language

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp