PieceMeta / node-sparql-hollandaise

A JS client lib to communicate with a triple store database through SPARQL queries over HTTP.
MIT License
3 stars 3 forks source link

Other SPARQL Features #4

Open martinleopold opened 8 years ago

martinleopold commented 8 years ago

Here's some more features from the SQARQL spec that might be implemented:

dasantonym commented 8 years ago

optional and union were already in the code. currently they work as follows:

let pattern1 = new GraphPattern(triple1),
    pattern2 = new GraphPattern([triple1, triple2], false, true), // second option sets UNION flag
    group = new GroupGraphPattern([pattern1, pattern2]);

and

let pattern1 = new GraphPattern(triple1),
    pattern2 = new GraphPattern([triple1, triple2], true, false), // first option sets OPTIONAL flag
    group = new GroupGraphPattern([pattern1, pattern2]);

not sure if this is the best way to represent it and i don't like the options in the constructor that much. i might update it to work like this:

let group = new GroupGraphPattern({
    $union: [pattern1, pattern2]
});

but first the subqueries... do you know if multiple subqueries are allowed? i couldn't really tell from the spec or i overlooked something.

dasantonym commented 8 years ago

subqueries are now also included. you can just add a query as an element to a graph pattern. the endpoint can be null for this subquery (it is ignored so set it to whatever you want). prefixes and base are skipped when converting the subquery to string.

var pattern = new GraphPattern([triple1, triple2, query]);