Skip to content

Instantly share code, notes, and snippets.

@warpr
Created January 3, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warpr/a4941fe3e0f4480a97de to your computer and use it in GitHub Desktop.
Save warpr/a4941fe3e0f4480a97de to your computer and use it in GitHub Desktop.
wald-query example

example

Here is a basic example which asks wikidata for some information about Britney Spears' Blackout album:

var wq = query.connect('ldf:http://data.wikidataldf.com/wikidata', ns);

var result = wq.query("wikidata:Q192755", {
    id: "@id",
    name: wq.literal (wq.first ("rdfs:label")),
    performer: wq.subquery ("wikidata:P175s", wq.subquery ("wikidata:P175v", {
        id: "@id",
        name: wq.first (wq.literal ("rdfs:label")),
    }))
});

wq.query() will return a promise which will resolve to:

{
    "id": "http://www.wikidata.org/entity/Q192755",
    "name": "Blackout",
    "performer": {
        "id": "http://www.wikidata.org/entity/Q11975",
        "name": "Britney Jean Spears"
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment