Show:

The Query is the root object for all SPARQL requests

Constructor

Query

(
  • endpoint
)

Parameters:

  • endpoint String
    • URL of the SPARQL endpoint

Methods

addPrefix

(
  • content
)

Add a prefix to the query

Parameters:

  • content Prefix | String | Array
    • A single Prefix string or object

ask

() Query

Set the current query to ASK

Returns:

Query:
  • Returns current instance (chainable)

base

(
  • content
)

Sets the base IRI

Parameters:

  • content String
    • BASE string

clearDatasetClauses

()

Clear current dataset clauses

clearPrefixes

()

Remove all Prefixes from the Query

construct

(
  • triples
)
Query

Set the current query to CONSTRUCT

Parameters:

  • triples Triple | Array
    • One or more Triples to be used for a DESCRIBE GraphPattern

Returns:

Query:
  • Returns current instance (chainable)

describe

(
  • content
)
Query

Set the current query to DESCRIBE

Parameters:

  • content String
    • Arguments given to the DESCRIBE statement

Returns:

Query:
  • Returns current instance (chainable)

exec

() Promise

Execute query

Returns:

Promise:
  • Returns a Promise with will yield a Result object

from

(
  • content
  • named
)
Query

Set dataset clause

Parameters:

  • content String | Array
    • One or more strings with dataset clauses (without FROM or NAMED)
  • named Boolean
    • Optional flag to set clause to NAMED

Returns:

Query:
  • Returns current instance (chainable)

getDatasetClauses

() Array

Get current dataset clauses

Returns:

Array:

getPrefixes

() Array

Get the Prefix objects of the Query

Returns:

Array:

getWhereClause

() GraphPattern | GroupGraphPattern

Get current where clause

limit

(
  • count
)
Query

Set limit for query

Parameters:

  • count Number
    • Limit count

Returns:

Query:
  • Returns current instance (chainable)

offset

(
  • count
)
Query

Set limit for offset

Parameters:

  • count Number
    • Offset count

Returns:

Query:
  • Returns current instance (chainable)

order

(
  • content
)
Query

Set order for query

Parameters:

  • content String
    • Order string without ORDER BY

Returns:

Query:
  • Returns current instance (chainable)

prefix

(
  • content
)
Query

Sets the prefix(es) for the query

Parameters:

  • content Prefix | String | Array
    • A single Prefix string or object or an array of Prefix objects or strings

Returns:

Query:
  • Returns current instance (chainable)

reset

()

Reset query (endpoint setting stays)

select

(
  • content
  • modifier
)
Query

Set the current query to SELECT

Parameters:

  • content String
    • Arguments given to the SELECT statement
  • modifier String
    • Optional modifier to be added (e.g. DISTINCT)

Returns:

Query:
  • Returns current instance (chainable)

toString

(
  • isSubquery
)
String

Retrieves the SPARQL string representation of the current instance, adding the FILTER keyword.

Parameters:

  • isSubquery Boolean
    • If set, skips the BASE and PREFIX parts for inclusion as a subquery

Returns:

String:

where

(
  • content
)
Query

Set where clause

Parameters:

  • content String | Array
    • A GraphPattern or a GroupGraphPattern object

Returns:

Query:
  • Returns current instance (chainable)