Creates an instance of Query. You should not have to manually create queries,
call dataCube.query()
instead since it will automatically pass data about the DataCube
to query.
The DataCube to query.
Retrieve the maximal and minimal values of a Component (Dimension, Measure, Attribute). See also DataCube.componentMinMax and the examples folder.
const values = await dataCube.componentMinMax(sizeDimensions);
// values = { min: literal(10), max: literal(600) }
const { min: sizeMin, max: sizeMax } = await dataCube.query()
.select({ size: sizeDimension })
.filter(({ size }) => size.gt(50))
.filter(({ size }) => size.lte(250))
.componentMinMax();
// sizeMin = 60, sizeMax = 250
Promise<{min: Literal|null, max: Literal|null}>
Retrieve all the possible values a Component (Dimension, Measure, Attribute) can have. See also DataCube.componentValues and the examples folder.
const sizeValues = await dataCube.query()
.select({ size: sizeDimension })
.filter(({ size }) => size.gt(50))
.filter(({ size }) => size.lte(250))
.componentValues();
}
Only return distinct values.
Executes the SPARQL query against the dataCube and returns the results.
Filter the results.
myDataCube
.query()
.select({
someDate: dateDimension,
})
// syntax 1:
.filter(({ someDate }) => someDate.not.equals("2019-08-29T07:27:56.241Z"));
// syntax 2:
.filter(dateDimension.not.equals("2019-08-29T07:27:56.241Z"));
// syntax 3:
.filter([dateDimension.not.equals("2019-08-29T07:27:56.241Z"), secondFilter, thirdFilter, moreFilters]);
Aggregate the results. Pass it a binding name used in .select()
or a function
({ bindingName }) => bindingName
myDataCube
.query()
.select({
someDimension: myDimension,
})
// syntax 1:
.groupBy(({ someDimension }) => someDimension)
// syntax 2:
.groupBy("someDimension")
Limit the number of results to return. Defaults to 10
, even when .limit()
is not used.
Use .limit(null)
to remove the default limit and get all results.
Results offset, number of results to ignore before returning the results.
Defaults to 0
. Usually used together with .limit
.
// return results 50 to 75
myDataCube
.query()
.limit(25)
.offset(50);
Adds one or many orderings to the results.
// order by `myVar DESC, otherVar`
myDataCube
.query({
myVar: someDimension,
otherVar: otherDimension,
})
// this:
.orderBy(({ myVar, otherVar }) => [myVar.desc(), otherVar]);
// is equivalent to:
.orderBy(someDimension.desc())
.orderBy(otherDimension);
// and equivalent to:
.orderBy(someDimension.desc(), otherDimension);
Decide what data needs to be returned by the query.
myDataCube
.query()
.select({
someDate: dateDimension,
});
Generates and returns the actual SPARQL query that would be .execute()
d.
Use it to preview the SPARQL query, to make sure your code generates what you
think it does.
SPARQL query
Generates the sparql.js select query that will be stringified to a SPARQL string by toSparql.
sparql.js select query
Generated using TypeDoc
A query to a DataCube.
Query
Options
Languages in which to get the labels, by priority, e.g.
["de", "en"]
. Inherited from DataCubeEntryPoint.