WOQL
License: Apache Version 2
The WOQL object is a wrapper around the WOQLQuery object Syntactic sugar to allow writing WOQL.triple()... instead of new WOQLQuery().triple() Every function matches one of the public api functions of the woql query object
WOQL.using(refPath, [subquery]) ⇒
WOQLQuery
Query running against any specific commit Id
Param | Type | Description |
---|---|---|
refPath | string | path to specific reference Id or commit Id |
[subquery] | WOQLQuery | subquery for the specific commit point |
Example
let [a, b, c] = vars("a", "b", "c")
WOQL.using("userName/dbName/local/commit|branch/commitID").triple(a, b, c)
WOQL.comment(comment, [subquery]) ⇒
WOQLQuery
Adds a text comment to a query - can also be used to wrap any part of a query to turn it off
Param | Type | Description |
---|---|---|
comment | string | text comment |
[subquery] | WOQLQuery | query that is "commented out" |
WOQL.select(varNames) ⇒
WOQLQuery
Param | Type | Description |
---|---|---|
varNames | string | Var | only these variables are returned |
Example
let [a, b, c] = vars("a", "b", "c")
WOQL.select(a, triple(a, b, c))
Filters the query so that only the variables included in [V1...Vn] are returned in the bindings
WOQL.distinct(varNames) ⇒
WOQLQuery
Filter the query to return only results that are distinct in the given variables
Param | Type | Description |
---|---|---|
varNames | string | Var | these variables are guaranteed to be unique as a tuple |
WOQL.and(...subqueries) ⇒
WOQLQuery
Logical conjunction of the contained queries - all queries must match or the entire clause fails
Returns:
WOQLQuery
- - A WOQLQuery object containing the conjunction of queriesParam | Type | Description |
---|---|---|
...subqueries | WOQLQuery | A list of one or more woql queries to execute as a conjunction |
Example
//find triples that are of type scm:Journey, and have
//a start_station Start, and that start_station is labeled Start_Label
let [Journey, Start, Start_Label] = vars("Journey", "Start", "Start_Label")
WOQL.and(
WOQL.triple(Journey, "rdf:type", "@schema:Journey"),
WOQL.triple(Journey, "start_station", Start),
WOQL.triple(Start, "label", Start_Label))
WOQL.read_object()
Deprecated
WOQL.read_document(IRI, output) ⇒
object
Read a node identified by an IRI as a JSON-LD document
Returns:
object
- WOQLQueryParam | Type | Description |
---|---|---|
IRI | string | The document id or a variable to read |
output | string | Variable which will be bound to the document. |
Example
let [person] = vars("Person")
const query = WOQL.read_document(
"Person/0b4feda109d9d13c9da809090b342ad9e4d8185545ce05f7cd20b97fe458f547",
person
);
const res = await client.query(query);
WOQL.insert_document(docjson, [IRI]) ⇒
object
Insert a document in the graph.
Returns:
object
- WOQLQueryParam | Type | Description |
---|---|---|
docjson | object | The document to insert. Must either have an '@id' or have a class specified key. |
[IRI] | string | An optional identifier specifying the document location. |
Example
const res = await client.query(
WOQL.insert_document(WOQL.doc({ "@type" : "Person", "label": "John" }))
)
WOQL.update_document(docjson, [IRI]) ⇒
object
Update a document identified by an IRI
Returns:
object
- WOQLQueryParam | Type | Description |
---|---|---|
docjson | object | The document to update. Must either have an '@id' or have a class specified key. |
[IRI] | string | An optional identifier specifying the document location. |
WOQL.delete_document(IRI) ⇒
object
Delete a document from the graph.
Returns:
object
- WOQLQueryParam | Type | Description |
---|---|---|
IRI | string | The document id or a variable |
WOQL.or(...subqueries) ⇒
WOQLQuery
Creates a logical OR of the arguments
Returns:
WOQLQuery
- - A WOQLQuery object containing the logical Or of the subqueriesParam | Type | Description |
---|---|---|
...subqueries | WOQLQuery | A list of one or more woql queries to execute as alternatives |
Example
let [Subject] = vars("Subject")
or(
triple(Subject, 'label', "A"),
triple(Subject, "label", "a")
)
WOQL.from(graphRef-, [query]) ⇒
WOQLQuery
Specifies the database URL that will be the default database for the enclosed query
Returns:
WOQLQuery
- A WOQLQuery object containing the from expressionParam | Type | Description |
---|---|---|
graphRef- | typedef.GraphRef | A valid graph resource identifier string |
[query] | WOQLQuery | The query |
WOQL.into(graphRef-, [subquery]) ⇒
WOQLQuery
Specifies the graph resource to write the contained query into
Returns:
WOQLQuery
- A WOQLQuery which will be written into the graph in questionParam | Type | Description |
---|---|---|
graphRef- | typedef.GraphRef | A valid graph resource identifier string |
[subquery] | WOQLQuery | The query which will be written into the graph |
Example
//Subq is an argument or a chained query
using("admin/minecraft").into("instance/main").add_triple("a", "rdf:type", "@schema:X")
//writes a single tripe (doc:a, rdf:type, scm:X) into the main instance graph
WOQL.triple(subject, predicate, object) ⇒
WOQLQuery
Creates a triple pattern matching rule for the triple [S, P, O] (Subject, Predicate, Object)
Param | Type | Description |
---|---|---|
subject | string | Var | The IRI of a triple’s subject or a variable |
predicate | string | Var | The IRI of a property or a variable |
object | string | Var | The IRI of a node or a variable, or a literal |
WOQL.added_triple(subject, predicate, object) ⇒
WOQLQuery
Creates a triple pattern matching rule for the triple [S, P, O] (Subject, Predicate, Object) added in the current layer
Param | Type | Description |
---|---|---|
subject | string | Var | The IRI of a triple’s subject or a variable |
predicate | string | Var | The IRI of a property or a variable |
object | string | Var | The IRI of a node or a variable, or a literal |
WOQL.removed_triple(subject, predicate, object) ⇒
WOQLQuery
Creates a triple pattern matching rule for the triple [S, P, O] (Subject, Predicate, Object) added in the current commit
Param | Type | Description |
---|---|---|
subject | string | Var | The IRI of a triple’s subject or a variable |
predicate | string | Var | The IRI of a property or a variable |
object | string | Var | The IRI of a node or a variable, or a literal |
WOQL.quad(subject, predicate, object, graphRef) ⇒
WOQLQuery
Creates a pattern matching rule for the quad [S, P, O, G] (Subject, Predicate, Object, Graph)
Param | Type | Description |
---|---|---|
subject | string | Var | The IRI of a triple’s subject or a variable |
predicate | string | Var | The IRI of a property or a variable |
object | string | Var | The IRI of a node or a variable, or a literal |
graphRef | typedef.GraphRef | A valid graph resource identifier string |
WOQL.added_quad(subject, predicate, object, graphRef-) ⇒
WOQLQuery
Creates a pattern matching rule for the quad [S, P, O, G] (Subject, Predicate, Object, Graph) removed from the current commit
Param | Type | Description |
---|---|---|
subject | string | Var | The IRI of a triple’s subject or a variable |
predicate | string | Var | The IRI of a property or a variable |
object | string | Var | The IRI of a node or a variable, or a literal |
graphRef- | typedef.GraphRef | A valid graph resource identifier string |
WOQL.removed_quad(subject, predicate, object, graphRef-) ⇒
WOQLQuery
Creates a pattern matching rule for the quad [S, P, O, G] (Subject, Predicate, Object, Graph) removed from the current commit
Param | Type | Description |
---|---|---|
subject | string | Var | The IRI of a triple’s subject or a variable |
predicate | string | Var | The IRI of a property or a variable |
object | string | Var | The IRI of a node or a variable, or a literal |
graphRef- | typedef.GraphRef | A valid graph resource identifier string |
WOQL.sub(classA, classB) ⇒
boolean
Returns true if ClassA subsumes ClassB, according to the current DB schema
Returns:
boolean
- WOQLQueryParam | Type | Description |
---|---|---|
classA | string | ClassA |
classB | string | ClassB |
WOQL.eq(varName, varValue) ⇒
WOQLQuery
Matches if a is equal to b
Param | Type | Description |
---|---|---|
varName | string | Var | literal, variable or id |
varValue | string | Var | literal, variable or id |
WOQL.substr(string, before, [length], [after], [substring]) ⇒
WOQLQuery
Substring
Param | Type | Description |
---|---|---|
string | string | Var | String or variable |
before | number | Var | integer or variable (characters from start to begin) |
[length] | number | Var | integer or variable (length of substring) |
[after] | number | Var | integer or variable (number of characters after substring) |
[substring] | string | Var | String or variable |
WOQL.get(asvars, queryResource) ⇒
WOQLQuery
Deprecated
Use the document inteface to import documents
Returns:
WOQLQuery
- A WOQLQuery which contains the get expressionParam | Type | Description |
---|---|---|
asvars | Vars | array.<Var> | an array of AsVar variable mappings (see as for format below) |
queryResource | WOQLQuery | an external resource (remote, file, post) to query |
Example
let [a, b] = vars("a", "b")
get(as("a", a).as("b", b)).remote("http://my.url.com/x.csv")
//copies the values from column headed "a" into a variable a and from column
//"b" into a variable b from remote CSV
WOQL.put(varsToExp, query, fileResource) ⇒
WOQLQuery
Deprecated
Use the document inteface to import documents
Returns:
WOQLQuery
- A WOQLQuery which contains the put expression
Put: Outputs the results of a query to a fileParam | Type | Description |
---|---|---|
varsToExp | Vars | array.<Var> | an array of AsVar variable mappings (see as for format below) |
query | WOQLQuery | The query which will be executed to produce the results |
fileResource | string | an file resource local to the server |
Example
let [s, p, o] = vars("Subject", "Predicate", "Object")
WOQL.put(WOQL.as("s", s).as("p", p).as("o", o), WOQL.all())
.file({file:"/app/local_files/dump.csv"})
WOQL.as(source, target, [type]) ⇒
WOQLQuery
Imports the value identified by Source to a Target variable
Param | Type | Description |
---|---|---|
source | string | number | Var | Source |
target | string | Var | Target |
[type] | string | type to cast value to string |
Example
let [First_Var, Second_Var] = vars('First_Var', 'Second_Var')
WOQL.as("first var", First_Var, "string").as("second var", Second_Var)
WOQL.as(["first var", First_Var, "string"], ["second var", Second_Var])
WOQL.remote(remoteObj, [formatObj]) ⇒
WOQLQuery
Identifies a remote resource by URL and specifies the format of the resource through the options
Returns:
WOQLQuery
- A WOQLQuery which contains the remote resource identifierParam | Type | Description |
---|---|---|
remoteObj | object | The URL at which the remote resource can be accessed |
[formatObj] | typedef.DataFormatObj | The format of the resource data {} |
Example
remote({url:"http://url.of.resource"}, {type: "csv"})
WOQL.post(url, [formatObj], [source]) ⇒
WOQLQuery
Identifies a resource as a local path on the client, to be sent to the server through a HTTP POST request, with the format defined through the options
Returns:
WOQLQuery
- A WOQLQuery which contains the Post resource identifierParam | Type | Description |
---|---|---|
url | string | The Path on the server at which the file resource can be accessed |
[formatObj] | typedef.DataFormatObj | imput options, optional |
[source] | string | It defines the source of the file, it can be 'url','post' |
Example
post("/.../.../", {type:'csv'})
WOQL.delete_triple(subject, predicate, object) ⇒
WOQLQuery
Deletes a single triple from the default graph of the database
Returns:
WOQLQuery
- - A WOQLQuery which contains the Triple Deletion statementParam | Type | Description |
---|---|---|
subject | string | Var | The IRI of a triple’s subject or a variable |
predicate | string | Var | The IRI of a property or a variable |
object | string | Var | The IRI of a node or a variable, or a literal |
Example
delete_triple("john", "age", 42)
WOQL.delete_quad(subject, predicate, object, graphRef) ⇒
WOQLQuery
Deletes a single triple from the graph [Subject, Predicate, Object, Graph]
Returns:
WOQLQuery
- - A WOQLQuery which contains the Delete Quad StatementParam | Type | Description |
---|---|---|
subject | string | Var | The IRI of a triple’s subject or a variable |
predicate | string | Var | The IRI of a property or a variable |
object | string | Var | The IRI of a node or a variable, or a literal |
graphRef | typedef.GraphRef | A valid graph resource identifier string |
Example
remove the class Person from the schema graph
WOQL.delete_quad("Person", "rdf:type", "sys:Class", "schema")
WOQL.add_triple(subject, predicate, object) ⇒
WOQLQuery
Adds triples according to the the pattern [subject,predicate,object]
Param | Type | Description |
---|---|---|
subject | string | Var | The IRI of a triple’s subject or a variable |
predicate | string | Var | The IRI of a property or a variable |
object | string | Var | The IRI of a node or a variable, or a literal |
WOQL.add_quad(subject, predicate, object, graphRef-) ⇒
WOQLQuery
Adds quads according to the pattern [S,P,O,G]
Param | Type | Description |
---|---|---|
subject | string | Var | The IRI of a triple’s subject or a variable |
predicate | string | Var | The IRI of a property or a variable |
object | string | Var | The IRI of a node or a variable, or a literal |
graphRef- | typedef.GraphRef | A valid graph resource identifier string |
WOQL.trim(inputStr, resultVarName) ⇒
WOQLQuery
Remove whitespace from both sides of a string:
Returns:
WOQLQuery
- A WOQLQuery which contains the Trim pattern matching expressionParam | Type | Description |
---|---|---|
inputStr | string | Var | A string or variable containing the untrimmed version of the string |
resultVarName | string | Var | A string or variable containing the trimmed version of the string |
Example
let [trimmed] = vars("trimmed")
trim("hello ", trimmed)
//trimmed contains "hello"
WOQL.evaluate(arithExp, resultVarName) ⇒
WOQLQuery
Evaluates the passed arithmetic expression and generates or matches the result value
Returns:
WOQLQuery
- A WOQLQuery which contains the Arithmetic functionParam | Type | Description |
---|---|---|
arithExp | object | WOQLQuery | string | A WOQL query containing a valid WOQL Arithmetic Expression, which is evaluated by the function |
resultVarName | string | number | Var | Either a variable, in which the result of the expression will be stored, or a numeric literal which will be used as a test of result of the evaluated expression |
Example
let [result] = vars("result")
evaluate(plus(2, minus(3, 1)), result)
WOQL.eval(arithExp, resultVarName) ⇒
WOQLQuery
Evaluates the passed arithmetic expression and generates or matches the result value
Returns:
WOQLQuery
- WOQLQueryParam | Type | Description |
---|---|---|
arithExp | object | WOQLQuery | string | query or JSON-LD representing the query |
resultVarName | string | Var | output variable |
WOQL.plus(...args) ⇒
WOQLQuery
Adds the numbers together
Returns:
WOQLQuery
- A WOQLQuery which contains the addition expressionParam | Type | Description |
---|---|---|
...args | string | number | Var | a variable or numeric containing the values to add |
Example
let [result] = vars("result")
evaluate(plus(2, plus(3, 1)), result)
WOQL.minus(...args) ⇒
WOQLQuery
Subtracts Numbers N1..Nn
Returns:
WOQLQuery
- A WOQLQuery which contains the subtraction expressionParam | Type | Description |
---|---|---|
...args | string | number | Var | variable or numeric containing the value that will be subtracted from |
Example
let [result] = vars("result")
evaluate(minus(2.1, plus(0.2, 1)), result)
WOQL.times(...args) ⇒
WOQLQuery
Multiplies numbers N1...Nn together
Returns:
WOQLQuery
- A WOQLQuery which contains the multiplication expression