mirror of
https://github.com/bpmbpm/doc.git
synced 2026-04-30 20:40:50 +00:00
Add files via upload
This commit is contained in:
parent
65e70b92a7
commit
dfa73c3f78
2 changed files with 45 additions and 0 deletions
39
test/comunica/sparql_file/sparql-file1_no.js
Normal file
39
test/comunica/sparql_file/sparql-file1_no.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
const QueryEngine = require('@comunica/query-sparql-file').QueryEngine;
|
||||
const myEngine = new QueryEngine();
|
||||
|
||||
const bindingsStream = await myEngine.queryBindings(`
|
||||
SELECT ?s ?p ?o WHERE {
|
||||
?s ?p <http://dbpedia.org/resource/Belgium>.
|
||||
?s ?p ?o
|
||||
} LIMIT 100`, {
|
||||
sources: ['http://fragments.dbpedia.org/2015/en'],
|
||||
});
|
||||
|
||||
// Consume results as a stream (best performance)
|
||||
bindingsStream.on('data', (binding) => {
|
||||
console.log(binding.toString()); // Quick way to print bindings for testing
|
||||
|
||||
console.log(binding.has('s')); // Will be true
|
||||
|
||||
// Obtaining values
|
||||
console.log(binding.get('s').value);
|
||||
console.log(binding.get('s').termType);
|
||||
console.log(binding.get('p').value);
|
||||
console.log(binding.get('o').value);
|
||||
});
|
||||
bindingsStream.on('end', () => {
|
||||
// The data-listener will not be called anymore once we get here.
|
||||
});
|
||||
bindingsStream.on('error', (error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
// Consume results as async iterable (easier)
|
||||
for await (const binding of bindingsStream) {
|
||||
console.log(binding.toString());
|
||||
}
|
||||
|
||||
// Consume results as an array (easier)
|
||||
const bindings = await bindingsStream.toArray();
|
||||
console.log(bindings[0].get('s').value);
|
||||
console.log(bindings[0].get('s').termType);
|
||||
Loading…
Add table
Add a link
Reference in a new issue