zazuko / query-rdf-data-cube

Explore or query RDF Data Cubes with a JavaScript API, without writing SPARQL.
https://zazuko.github.io/query-rdf-data-cube/
9 stars 2 forks source link

feat(query): skos:broader support to fetch or fix a parent dimension #46

Closed vhf closed 4 years ago

vhf commented 4 years ago

Dimensions have a .broader() method to select the skos:broader.

Examples based on data where you'd have things in a City with city skos:broader country country skos:broader continent.

const city: Dimension;
const country = city.broader();
const continent = country.broader();

// get cities, and the country and continent they are in
const query = dataCube.query().select({
  city,
  country,
  continent,
});
const sparql = await query.toSparql();
console.log(sparql);
const city: Dimension;
const country = city.broader();

// get cities, and the continent they are in
const query = dataCube.query().select({
  city,
  continent: city.broader().broader(),
});
const sparql = await query.toSparql();
console.log(sparql);
const city: Dimension;
const country = city.broader();

// get cities in Asia
const query = dataCube.query().select({
  city,
  continent: city.broader().broader("http://my.namespace.com/thing/continent/Asia"),
});
const sparql = await query.toSparql();
console.log(sparql);

@herrstucki I heard you once had a need for this? (We definitely do.)


TODO

jstcki commented 4 years ago

@vhf Yes, definitely! I haven't thought about this in detail, but it looks very useful. A few first comments:

/cc @lucguillemot

ktk commented 4 years ago

@herrstucki all good questions but I propose we move them to next year. We are definitely out of hours.

vhf commented 4 years ago

@zazuko/query-rdf-data-cube@0.7.0