@zazuko/query-rdf-data-cube - v0.7.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

A query to a DataCube.

class

Query

param

Options

param

Languages in which to get the labels, by priority, e.g. ["de", "en"]. Inherited from DataCubeEntryPoint.

Hierarchy

  • Query

Index

Constructors

constructor

  • 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.

    Parameters

    Returns Query

Methods

componentMinMax

  • componentMinMax(): Promise<object>
  • 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

    Returns Promise<object>

    Promise<{min: Literal|null, max: Literal|null}>

componentValues

  • componentValues(): Promise<Array<object>>
  • 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();

    Returns Promise<Array<object>>

    }

distinct

  • distinct(distinct?: boolean): Query
  • Only return distinct values.

    Parameters

    • Default value distinct: boolean = true

    Returns Query

execute

  • Executes the SPARQL query against the dataCube and returns the results.

    Returns QueryResult

filter

  • 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]);

    Parameters

    Returns Query

groupBy

  • 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")

    Parameters

    Returns Query

having

limit

  • limit(limit: number | null): Query
  • 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.

    Parameters

    • limit: number | null

    Returns Query

offset

  • offset(offset: number): Query
  • 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);

    Parameters

    • offset: number

    Returns Query

orderBy

  • orderBy(...orderings: Component[] | PredicatesFunction[]): Query
  • 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);

    Parameters

    • Rest ...orderings: Component[] | PredicatesFunction[]

    Returns Query

select

toSparql

  • toSparql(sparqlJS?: SelectQuery): Promise<string>
  • 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.

    Parameters

    • Optional sparqlJS: SelectQuery

    Returns Promise<string>

    SPARQL query

toSparqlJS

  • toSparqlJS(): Promise<SelectQuery>
  • Generates the sparql.js select query that will be stringified to a SPARQL string by toSparql.

    Returns Promise<SelectQuery>

    sparql.js select query

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc