WOQL
WOQL
License: Apache Version 2
new WOQL()
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
using
WOQL.using(refPath, [subquery]) ⇒ WOQLQuery
Query running against any specific commit Id
Param | Type | Description |
---|---|---|
refPath |
| path to specific reference Id or commit Id |
[subquery] |
| subquery for the specific commit point |
Example
comment
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 |
| text comment |
[subquery] |
| query that is "commented out" |
select
WOQL.select(varNames) ⇒ WOQLQuery
Param | Type | Description |
---|---|---|
varNames |
| only these variables are returned |
Example
distinct
WOQL.distinct(varNames) ⇒ WOQLQuery
Filter the query to return only results that are distinct in the given variables
Param | Type | Description |
---|---|---|
varNames |
| these variables are guaranteed to be unique as a tuple |
and
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 queries
Param | Type | Description |
---|---|---|
...subqueries |
| A list of one or more woql queries to execute as a conjunction |
Example
read_object
WOQL.read_object()
Deprecated
Use read_document instead.
read_document
WOQL.read_document(IRI, output) ⇒ object
Read a node identified by an IRI as a JSON-LD document
Returns: object
- WOQLQuery
Param | Type | Description |
---|---|---|
IRI |
| The document id or a variable to read |
output |
| Variable which will be bound to the document. |
Example
insert_document
WOQL.insert_document(docjson, [IRI]) ⇒ object
Insert a document in the graph.
Returns: object
- WOQLQuery
Param | Type | Description |
---|---|---|
docjson |
| The document to insert. Must either have an '@id' or have a class specified key. |
[IRI] |
| An optional identifier specifying the document location. |
Example
update_document
WOQL.update_document(docjson, [IRI]) ⇒ object
Update a document identified by an IRI
Returns: object
- WOQLQuery
Param | Type | Description |
---|---|---|
docjson |
| The document to update. Must either have an '@id' or have a class specified key. |
[IRI] |
| An optional identifier specifying the document location. |
delete_document
WOQL.delete_document(IRI) ⇒ object
Delete a document from the graph.
Returns: object
- WOQLQuery
Param | Type | Description |
---|---|---|
IRI |
| The document id or a variable |
or
WOQL.or(...subqueries) ⇒ WOQLQuery
Creates a logical OR of the arguments
Returns: WOQLQuery
- - A WOQLQuery object containing the logical Or of the subqueries
Param | Type | Description |
---|---|---|
...subqueries |
| A list of one or more woql queries to execute as alternatives |
Example
from
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 expression
Param | Type | Description |
---|---|---|
graphRef- |
| A valid graph resource identifier string |
[query] |
| The query |
into
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 question
Param | Type | Description |
---|---|---|
graphRef- |
| A valid graph resource identifier string |
[subquery] |
| The query which will be written into the graph |
Example
triple
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 |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
object |
| The IRI of a node or a variable, or a literal |
added_triple
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 |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
object |
| The IRI of a node or a variable, or a literal |
removed_triple
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 |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
object |
| The IRI of a node or a variable, or a literal |
quad
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 |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
object |
| The IRI of a node or a variable, or a literal |
graphRef |
| A valid graph resource identifier string |
added_quad
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 |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
object |
| The IRI of a node or a variable, or a literal |
graphRef- |
| A valid graph resource identifier string |
removed_quad
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 |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
object |
| The IRI of a node or a variable, or a literal |
graphRef- |
| A valid graph resource identifier string |
sub
WOQL.sub(classA, classB) ⇒ boolean
Returns true if ClassA subsumes ClassB, according to the current DB schema
Returns: boolean
- WOQLQuery
Param | Type | Description |
---|---|---|
classA |
| ClassA |
classB |
| ClassB |
eq
WOQL.eq(varName, varValue) ⇒ WOQLQuery
Matches if a is equal to b
Param | Type | Description |
---|---|---|
varName |
| literal, variable or id |
varValue |
| literal, variable or id |
substr
WOQL.substr(string, before, [length], [after], [substring]) ⇒ WOQLQuery
Substring
Param | Type | Description |
---|---|---|
string |
| String or variable |
before |
| integer or variable (characters from start to begin) |
[length] |
| integer or variable (length of substring) |
[after] |
| integer or variable (number of characters after substring) |
[substring] |
| String or variable |
get
WOQL.get(asvars, queryResource) ⇒ WOQLQuery
Deprecated
Use the document inteface to import documents
Returns: WOQLQuery
- A WOQLQuery which contains the get expression
Param | Type | Description |
---|---|---|
asvars |
| an array of AsVar variable mappings (see as for format below) |
queryResource |
| an external resource (remote, file, post) to query |
Example
put
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 file
Param | Type | Description |
---|---|---|
varsToExp |
| an array of AsVar variable mappings (see as for format below) |
query |
| The query which will be executed to produce the results |
fileResource |
| an file resource local to the server |
Example
as
WOQL.as(source, target, [type]) ⇒ WOQLQuery
Imports the value identified by Source to a Target variable
Param | Type | Description |
---|---|---|
source |
| Source |
target |
| Target |
[type] |
| type to cast value to string |
Example
remote
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 identifier
Param | Type | Description |
---|---|---|
remoteObj |
| The URL at which the remote resource can be accessed |
[formatObj] |
| The format of the resource data {} |
Example
post
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 identifier
Param | Type | Description |
---|---|---|
url |
| The Path on the server at which the file resource can be accessed |
[formatObj] |
| imput options, optional |
[source] |
| It defines the source of the file, it can be 'url','post' |
Example
delete_triple
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 statement
Param | Type | Description |
---|---|---|
subject |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
object |
| The IRI of a node or a variable, or a literal |
Example
delete_quad
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 Statement
Param | Type | Description |
---|---|---|
subject |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
object |
| The IRI of a node or a variable, or a literal |
graphRef |
| A valid graph resource identifier string |
Example
add_triple
WOQL.add_triple(subject, predicate, object) ⇒ WOQLQuery
Adds triples according to the the pattern [subject,predicate,object]
Param | Type | Description |
---|---|---|
subject |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
object |
| The IRI of a node or a variable, or a literal |
add_quad
WOQL.add_quad(subject, predicate, object, graphRef-) ⇒ WOQLQuery
Adds quads according to the pattern [S,P,O,G]
Param | Type | Description |
---|---|---|
subject |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
object |
| The IRI of a node or a variable, or a literal |
graphRef- |
| A valid graph resource identifier string |
trim
WOQL.trim(inputStr, resultVarName) ⇒ WOQLQuery
Remove whitespace from both sides of a string:
Returns: WOQLQuery
- A WOQLQuery which contains the Trim pattern matching expression
Param | Type | Description |
---|---|---|
inputStr |
| A string or variable containing the untrimmed version of the string |
resultVarName |
| A string or variable containing the trimmed version of the string |
Example
evaluate
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 function
Param | Type | Description |
---|---|---|
arithExp |
| A WOQL query containing a valid WOQL Arithmetic Expression, which is evaluated by the function |
resultVarName |
| 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
eval
WOQL.eval(arithExp, resultVarName) ⇒ WOQLQuery
Evaluates the passed arithmetic expression and generates or matches the result value
Returns: WOQLQuery
- WOQLQuery
Param | Type | Description |
---|---|---|
arithExp |
| query or JSON-LD representing the query |
resultVarName |
| output variable |
plus
WOQL.plus(...args) ⇒ WOQLQuery
Adds the numbers together
Returns: WOQLQuery
- A WOQLQuery which contains the addition expression
Param | Type | Description |
---|---|---|
...args |
| a variable or numeric containing the values to add |
Example
minus
WOQL.minus(...args) ⇒ WOQLQuery
Subtracts Numbers N1..Nn
Returns: WOQLQuery
- A WOQLQuery which contains the subtraction expression
Param | Type | Description |
---|---|---|
...args |
| variable or numeric containing the value that will be subtracted from |
Example
times
WOQL.times(...args) ⇒ WOQLQuery
Multiplies numbers N1...Nn together
Returns: WOQLQuery
- A WOQLQuery which contains the multiplication expression
Param | Type | Description |
---|---|---|
...args |
| a variable or numeric containing the value |
Example
divide
WOQL.divide(...args) ⇒ WOQLQuery
Divides numbers N1...Nn by each other left, to right precedence
Returns: WOQLQuery
- A WOQLQuery which contains the division expression let [result] = vars("result") evaluate(divide(times(10, minus(2.1, plus(0.2, 1))), 10), result) //result contains 0.9000000000000001
Param | Type | Description |
---|---|---|
...args |
| numbers to tbe divided |
div
WOQL.div(...args) ⇒ WOQLQuery
Division - integer division - args are divided left to right
Returns: WOQLQuery
- A WOQLQuery which contains the division expression
Param | Type | Description |
---|---|---|
...args |
| numbers for division |
Example
exp
WOQL.exp(varNum, expNum) ⇒ WOQLQuery
Exponent - raises varNum01 to the power of varNum02
Returns: WOQLQuery
- A WOQLQuery which contains the exponent expression
Param | Type | Description |
---|---|---|
varNum |
| a variable or numeric containing the number to be raised to the power of the second number |
expNum |
| a variable or numeric containing the exponent |
Example
floor
WOQL.floor(varNum) ⇒ WOQLQuery
Generates the nearest lower integer to the passed number
Returns: WOQLQuery
- A WOQLQuery which contains the floor expression
Param | Type | Description |
---|---|---|
varNum |
| Variable or numeric containing the number to be floored |
Example
isa
WOQL.isa(instanceIRI, classId) ⇒ WOQLQuery
Tests whether a given instance IRI has type Class, according to the current state of the DB
Returns: WOQLQuery
- A WOQLQuery object containing the type test
Param | Type | Description |
---|---|---|
instanceIRI |
| A string IRI or a variable that identify the class instance |
classId |
| A Class IRI or a variable |
Example
like
WOQL.like(stringA, stringB, distance) ⇒ WOQLQuery
Generates a string Leverstein distance measure between stringA and stringB
Returns: WOQLQuery
- A WOQLQuery which contains the Like pattern matching expression
Param | Type | Description |
---|---|---|
stringA |
| string literal or variable representing a string to be compared |
stringB |
| string literal or variable representing the other string to be compared |
distance |
| variable representing the distance between the variables |
Example
less
WOQL.less(varNum01, varNum02) ⇒ WOQLQuery
Compares the value of v1 against v2 and returns true if v1 is less than v2
Returns: WOQLQuery
- A WOQLQuery which contains the comparison expression
Param | Type | Description |
---|---|---|
varNum01 |
| a variable or numeric containing the number to be compared |
varNum02 |
| a variable or numeric containing the second comporator |
Example
greater
WOQL.greater(varNum01, varNum02) ⇒ WOQLQuery
Compares the value of v1 against v2 and returns true if v1 is greater than v2
Returns: WOQLQuery
- A WOQLQuery which contains the comparison expression
Param | Type | Description |
---|---|---|
varNum01 |
| a variable or numeric containing the number to be compared |
varNum02 |
| a variable or numeric containing the second comporator |
Example
opt
WOQL.opt([subquery]) ⇒ WOQLQuery
Specifies that the Subquery is optional - if it does not match the query will not fail
Returns: WOQLQuery
- A WOQLQuery object containing the optional sub Query
Param | Type | Description |
---|---|---|
[subquery] |
| A subquery which will be optionally matched |
Example
unique
WOQL.unique(prefix, inputVarList, resultVarName) ⇒ WOQLQuery
Generate a new IRI from the prefix and a hash of the variables which will be unique for any given combination of variables
Returns: WOQLQuery
- A WOQLQuery object containing the unique ID generating function
Param | Type | Description |
---|---|---|
prefix |
| A prefix for the IRI - typically formed of the doc prefix and the classtype of the entity (“doc:Person”) |
inputVarList |
| An array of variables and / or strings from which the unique hash will be generated |
resultVarName |
| Variable in which the unique ID is stored |
Example
idgen
WOQL.idgen(prefix, inputVarList, resultVarName) ⇒ WOQLQuery
Generate a new IRI from the prefix and concatention of the variables
Returns: WOQLQuery
- A WOQLQuery object containing the ID generating function
Param | Type | Description |
---|---|---|
prefix |
| A prefix for the IRI - typically formed of the doc prefix and the classtype of the entity (“doc:Person”) |
inputVarList |
| An array of variables and / or strings from which the unique hash will be generated |
resultVarName |
| Variable in which the unique ID is stored |
Example
upper
WOQL.upper(inputVarName, resultVarName) ⇒ WOQLQuery
Changes a string to upper-case
Returns: WOQLQuery
- A WOQLQuery which contains the Upper case pattern matching expression
Param | Type | Description |
---|---|---|
inputVarName |
| string or variable representing the uncapitalized string |
resultVarName |
| variable that stores the capitalized string output |
Example
lower
WOQL.lower(inputVarName, resultVarName) ⇒ WOQLQuery
Changes a string to lower-case
Returns: WOQLQuery
- A WOQLQuery which contains the Lower case pattern matching expression
Param | Type | Description |
---|---|---|
inputVarName |
| string or variable representing the non-lowercased string |
resultVarName |
| variable that stores the lowercased string output |
Example
pad
WOQL.pad(inputVarName, pad, len, resultVarName) ⇒ WOQLQuery
Pads out the string input to be exactly len long by appending the pad character pad to form output
Returns: WOQLQuery
- A WOQLQuery which contains the Pad pattern matching expression
Param | Type | Description |
---|---|---|
inputVarName |
| The input string or variable in unpadded state |
pad |
| The characters to use to pad the string or a variable representing them |
len |
| The variable or integer value representing the length of the output string |
resultVarName |
| stores output |
Example
split
WOQL.split(inputVarName, separator, resultVarName) ⇒ WOQLQuery
Splits a string (Input) into a list strings (Output) by removing separator
Returns: WOQLQuery
- A WOQLQuery which contains the Split pattern matching expression
Param | Type | Description |
---|---|---|
inputVarName |
| A string or variable representing the unsplit string |
separator |
| A string or variable containing a sequence of charatcters to use as a separator |
resultVarName |
| variable that stores output list |
Example
member
WOQL.member(element, list) ⇒ WOQLQuery
Matches if List includes Element
Returns: WOQLQuery
- A WOQLQuery which contains the List inclusion pattern matching expression
Param | Type | Description |
---|---|---|
element |
| Either a variable, IRI or any simple datatype |
list |
| List ([string, literal] or string*) Either a variable representing a list or a list of variables or literals |
Example
concat
WOQL.concat(varList, resultVarName) ⇒ WOQLQuery
takes a variable number of string arguments and concatenates them into a single string
Returns: WOQLQuery
- A WOQLQuery which contains the Concatenation pattern matching expression
Param | Type | Description |
---|---|---|
varList |
| a variable representing a list or a list of variables or strings - variables can be embedded in the string if they do not contain spaces |
resultVarName |
| A variable or string containing the output string |
Example
join
WOQL.join(varList, glue, resultVarName) ⇒ WOQLQuery
Joins a list variable together (Input) into a string variable (Output) by glueing the strings together with Glue
Returns: WOQLQuery
- A WOQLQuery which contains the Join pattern matching expression
Param | Type | Description |
---|---|---|
varList |
| a variable representing a list or a list of strings and / or variables |
glue |
| A variable (v:glue) or (glue) string representing the characters to put in between the joined strings in input |
resultVarName |
| A variable or string containing the output string |
Example
sum
WOQL.sum(subquery, total) ⇒ WOQLQuery
computes the sum of the List of values passed. In contrast to other arithmetic functions, sum self-evaluates - it does not have to be passed to evaluate()
Returns: WOQLQuery
- - A WOQLQuery which contains the Sum expression
Param | Type | Description |
---|---|---|
subquery |
| a subquery or ([string or numeric]) - a list variable, or a list of variables or numeric literals |
total |
| the variable name with the sum result of the values in List |
Example
start
WOQL.start(start, [subquery]) ⇒ WOQLQuery
Specifies an offset position in the results to start listing results from
Returns: WOQLQuery
- A WOQLQuery whose results will be returned starting from the specified offset
Param | Type | Description |
---|---|---|
start |
| A variable that refers to an interger or an integer literal |
[subquery] |
| WOQL Query object, you can pass a subquery as an argument or a chained query |
Example
limit
WOQL.limit(limit, [subquery]) ⇒ WOQLQuery
Specifies a maximum number of results that will be returned from the subquery
Returns: WOQLQuery
- A WOQLQuery whose results will be returned starting from the specified offset
Param | Type | Description |
---|---|---|
limit |
| A variable that refers to an non-negative integer or a non-negative integer |
[subquery] |
| A subquery whose results will be limited |
Example
re
WOQL.re(pattern, inputVarName, resultVarList) ⇒ WOQLQuery
Matches the regular expression defined in Patern against the Test string, to produce the matched patterns in Matches
Returns: WOQLQuery
- A WOQLQuery which contains the Regular Expression pattern matching expression
Param | Type | Description |
---|---|---|
pattern |
| string or variable using normal PCRE regular expression syntax with the exception that special characters have to be escaped twice (to enable transport in JSONLD) |
inputVarName |
| string or variable containing the string to be tested for patterns with the regex |
resultVarList |
| variable representing the list of matches or a list of strings or variables |
Example
length
WOQL.length(inputVarList, resultVarName) ⇒ WOQLQuery
Calculates the length of the list in va and stores it in vb
Returns: WOQLQuery
- A WOQLQuery which contains the Length pattern matching expression
Param | Type | Description |
---|---|---|
inputVarList |
| Either a variable representing a list or a list of variables or literals |
resultVarName |
| A variable in which the length of the list is stored or the length of the list as a non-negative integer |
Example
not
WOQL.not([subquery]) ⇒ WOQLQuery
Logical negation of the contained subquery - if the subquery matches, the query will fail to match
Returns: WOQLQuery
- A WOQLQuery object containing the negated sub Query
Param | Type | Description |
---|---|---|
[subquery] |
| A subquery which will be negated |
Example
once
WOQL.once([subquery]) ⇒ WOQLQuery
Results in one solution of the subqueries
Returns: WOQLQuery
- A WOQLQuery object containing the once sub Query
Param | Type | Description |
---|---|---|
[subquery] |
| WOQL Query objects |
immediately
WOQL.immediately([subquery]) ⇒ WOQLQuery
Runs the query without backtracking on side-effects
Returns: WOQLQuery
- A WOQLQuery object containing the immediately sub Query
Param | Type | Description |
---|---|---|
[subquery] |
| WOQL Query objects |
count
WOQL.count(countVarName, [subquery]) ⇒ WOQLQuery
Creates a count of the results of the query
Returns: WOQLQuery
- A WOQLQuery object containing the count sub Query
Param | Type | Description |
---|---|---|
countVarName |
| variable or integer count |
[subquery] |
|
Example
typecast
WOQL.typecast(varName, varType, resultVarName) ⇒ WOQLQuery
Casts the value of Input to a new value of type Type and stores the result in CastVar
Returns: WOQLQuery
- A WOQLQuery which contains the casting expression
Param | Type | Description |
---|---|---|
varName |
| Either a single variable or a literal of any basic type |
varType |
| Either a variable or a basic datatype (xsd / xdd) |
resultVarName |
| save the return variable |
Example
order_by
WOQL.order_by(varNames) ⇒ WOQLQuery
Orders the results of the contained subquery by a precedence list of variables
Returns: WOQLQuery
- A WOQLQuery which contains the ordering expression
Param | Type | Description |
---|---|---|
varNames |
| A sequence of variables, by which to order the results, each optionally followed by either “asc” or “desc” to represent order as a list, by default it will sort the variable in ascending order |
Example
group_by
WOQL.group_by(varList, patternVars, resultVarName, [subquery]) ⇒ WOQLQuery
Groups the results of the contained subquery on the basis of identical values for Groupvars, extracts the patterns defined in PatternVars and stores the results in GroupedVar
Returns: WOQLQuery
- A WOQLQuery which contains the grouping expression
Param | Type | Description |
---|---|---|
varList |
| Either a single variable or an array of variables |
patternVars |
| Either a single variable or an array of variables |
resultVarName |
| output variable name |
[subquery] |
| The query whose results will be grouped |
Example
true
WOQL.true() ⇒ WOQLQuery
A function that always matches, always returns true
Returns: WOQLQuery
- A WOQLQuery object containing the true value that will match any pattern
Example
path
WOQL.path(subject, pattern, object, [resultVarName]) ⇒ WOQLQuery
Performs a path regular expression match on the graph
Returns: WOQLQuery
- - A WOQLQuery which contains the path regular expression matching expression
Param | Type | Description |
---|---|---|
subject |
| An IRI or variable that refers to an IRI representing the subject, i.e. the starting point of the path |
pattern |
| (string) - A path regular expression describing a pattern through multiple edges of the graph (see: https://terminusdb.com/docs/index/terminusx-db/how-to-guides/path-queries) |
object |
| An IRI or variable that refers to an IRI representing the object, i.e. ending point of the path |
[resultVarName] |
| A variable in which the actual paths traversed will be stored |
Example
size
WOQL.size(resourceId, resultVarName)
Calculates the size in bytes of the contents of the resource identified in ResourceID
Param | Type | Description |
---|---|---|
resourceId |
| A valid resource identifier string (can refer to any graph / branch / commit / db) |
resultVarName |
| The variable name |
Example
triple_count
WOQL.triple_count(resourceId, tripleCount) ⇒ WOQLQuery
Calculates the number of triples of the contents of the resource identified in ResourceID
Returns: WOQLQuery
- A WOQLQuery which contains the size expression
Param | Type | Description |
---|---|---|
resourceId |
| A valid resource identifier string (can refer to any graph / branch / commit / db) |
tripleCount |
| An integer literal with the size in bytes or a variable containing that integer |
Example
type_of
WOQL.type_of(elementId, elementType) ⇒ WOQLQuery
Returns true if 'elementId' is of type 'elementType', according to the current DB schema
Returns: WOQLQuery
- A WOQLQuery object containing the type_of pattern matching rule
Param | Type | Description |
---|---|---|
elementId |
| the id of a schema graph element |
elementType |
| the element type |
star
WOQL.star([graph], [subject], [predicate], [object]) ⇒ WOQLQuery
Generates a query that by default matches all triples in a graph identified by "graph" or in all the current terminusDB's graph
Returns: WOQLQuery
- A WOQLQuery which contains the pattern matching expression
Param | Type | Description |
---|---|---|
[graph] |
| false or the resource identifier of a graph possible value are schema/{main - myschema - *} |
[subject] |
| The IRI of a triple’s subject or a variable, default value "v:Subject" |
[predicate] |
| The IRI of a property or a variable, default value "v:Predicate" |
[object] |
| The IRI of a node or a variable, or a literal, default value "v:Object" |
Example
all
WOQL.all([subject], [predicate], [object], [graphRef]) ⇒ WOQLQuery
Generates a query that by default matches all triples in a graph - identical to star() except for order of arguments
Returns: WOQLQuery
- - A WOQLQuery which contains the pattern matching expression all("mydoc") //will return every triple in the instance/main graph that has "doc:mydoc" as its subject
Param | Type | Description |
---|---|---|
[subject] |
| The IRI of a triple’s subject or a variable |
[predicate] |
| The IRI of a property or a variable |
[object] |
| The IRI of a node or a variable, or a literal |
[graphRef] |
| the resource identifier of a graph possible value are schema/{main - myschema - *} |
node
WOQL.node(nodeid, [chainType]) ⇒ WOQLQuery
Specifies the identity of a node that can then be used in subsequent builder functions. Note that node() requires subsequent chained functions to complete the triples / quads that it produces - by itself it only generates the subject.
Returns: WOQLQuery
- - A WOQLQuery which contains the partial Node pattern matching expression
Param | Type | Description |
---|---|---|
nodeid |
| The IRI of a node or a variable containing an IRI which will be the subject of the builder functions |
[chainType] |
| Optional type of builder function to build (default is triple) |
Example
insert
WOQL.insert(classId, classType, [graphRef]) ⇒ WOQLQuery
Inserts a single triple into the database declaring the Node to have type Type, optionally into the specified graph
Returns: WOQLQuery
- A WOQLQuery which contains the insert expression
Param | Type | Description |
---|---|---|
classId |
| IRI string or variable containing the IRI of the node to be inserted |
classType |
| IRI string or variable containing the IRI of the type of the node (class/document name) |
[graphRef] |
| Optional Graph resource identifier |
Example
graph
WOQL.graph([graphRef]) ⇒ WOQLQuery
Sets the graph resource ID that will be used for subsequent chained function calls
Returns: WOQLQuery
- A WOQLQuery which contains the partial Graph pattern matching expression
Param | Type | Description |
---|---|---|
[graphRef] |
| Resource String identifying the graph which will be used for subsequent chained schema calls |
Example
nuke
WOQL.nuke([graphRef]) ⇒ WOQLQuery
Deletes all triples in the passed graph (defaults to instance/main)
Returns: WOQLQuery
- - A WOQLQuery which contains the deletion expression
Param | Type | Description |
---|---|---|
[graphRef] |
| Resource String identifying the graph from which all triples will be removed |
Example
query
WOQL.query() ⇒ WOQLQuery
Generates an empty WOQLQuery object
Example
json
WOQL.json([JSON_LD]) ⇒ WOQLQuery
| object
Generates a WOQLQuery object from the passed WOQL JSON - if an argument is passed, the query object is created from it, if none is passed, the current state is returned as a JSON-LD
Returns: WOQLQuery
| object
- either a JSON-LD or a WOQLQuery object
json version of query for passing to api
Param | Type | Description |
---|---|---|
[JSON_LD] |
| JSON-LD woql document encoding a query |
lib
WOQL.lib() ⇒ WOQLQuery
get the predefined library query WOQLLibrary
Returns: WOQLQuery
- WOQLQuery object
Example
string
WOQL.string(val) ⇒ object
Generates explicitly a JSON-LD string literal from the input
Returns: object
- - A JSON-LD string literal
Param | Type | Description |
---|---|---|
val |
| any primitive literal type |
Example
literal
WOQL.literal(val, type) ⇒ object
Generates explicitly a JSON-LD string literal from the input
Returns: object
- - A JSON-LD literal
Param | Type | Description |
---|---|---|
val |
| any literal type |
type |
| an xsd or xdd type |
Example
date
WOQL.date(date) ⇒ object
Generates explicitly a JSON-LD literal date from the imput
Returns: object
- - A JSON-LD literal date
Param | Type | Description |
---|---|---|
date |
| any date format string (YYYY-MM-DD) |
Example
datetime
WOQL.datetime(datetime) ⇒ object
Generates explicitly a JSON-LD literal datetime from the imput
Returns: object
- - A JSON-LD literal datetime
Param | Type | Description |
---|---|---|
datetime |
| any datetime format string (YYYY-MM-DDThh-mm-ssZ) |
Example
boolean
WOQL.boolean(bool) ⇒ object
Generates explicitly a JSON-LD literal boolean from the input
Returns: object
- - A JSON-LD literal boolean
Param | Type | Description |
---|---|---|
bool |
| true |
Example
iri
WOQL.iri(val) ⇒ object
Explicitly sets a value to be an IRI - avoiding automatic type marshalling
Returns: object
- - A JSON-LD IRI value
Param | Type | Description |
---|---|---|
val |
| string which will be treated as an IRI |
vars
WOQL.vars(...varNames) ⇒ array.<Var>
Generates javascript variables for use as WOQL variables within a query
Returns: array.<Var>
- an array of javascript variables which can be dereferenced using the array destructuring operation
Param | Type |
---|---|
...varNames |
|
Example
doc
WOQL.doc(object) ⇒ object
Produces an encoded form of a document that can be used by a WOQL operation such as WOQL.insert_document
.
Returns: object
- The encoded document
Param | Type | Description |
---|---|---|
object |
| Document to encode |
Example
client
WOQL.client(client) ⇒ WOQLClient
Gets/Sets woqlClient
Param | Type |
---|---|
client |
|
Vars
WOQL.Vars(...varNames) ⇒ object.<Var>
Param | Type |
---|---|
...varNames |
|
Example
emerge
WOQL.emerge(auto_eval)
query module allow you to use WOQL words as top level functions
Param | Type |
---|---|
auto_eval |
|
update_triple
WOQL.update_triple(subject, predicate, newObjValue, oldObjValue) ⇒ WOQLQuery
Update a pattern matching rule for the triple (Subject, Predicate, oldObjValue) with the new one (Subject, Predicate, newObjValue)
Returns: WOQLQuery
- A WOQLQuery which contains the a Update Triple Statement
Param | Type | Description |
---|---|---|
subject |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
newObjValue |
| The value to update or a literal |
oldObjValue |
| The old value of the object |
update_quad
WOQL.update_quad(subject, predicate, newObject, graphRef) ⇒ WOQLQuery
Update a pattern matching rule for the quad [S, P, O, G] (Subject, Predicate, Object, Graph)
Returns: WOQLQuery
- A WOQLQuery which contains the a Update Quad Statement
Param | Type | Description |
---|---|---|
subject |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
newObject |
| The value to update or a literal |
graphRef |
| A valid graph resource identifier string |
value
WOQL.value(subject, predicate, objValue) ⇒ WOQLQuery
Creates a pattern matching rule for a triple [Subject, Predicate, Object] add extra information about the type of the value object
Returns: WOQLQuery
- A WOQLQuery which contains the a quad or a triple Statement
Param | Type | Description |
---|---|---|
subject |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
objValue |
| an specific value |
link
WOQL.link(subject, predicate, object) ⇒ WOQLQuery
Creates a pattern matching rule for a triple [Subject, Predicate, Object]
Returns: WOQLQuery
- A WOQLQuery which contains the a quad or a triple Statement
Param | Type | Description |
---|---|---|
subject |
| The IRI of a triple’s subject or a variable |
predicate |
| The IRI of a property or a variable |
object |
| The IRI of a node or a variable, or a literal |
dot
WOQL.dot(document, field, value) ⇒ WOQLQuery
Extract the value of a key in a bound document.
Returns: WOQLQuery
- A WOQLQuery which contains the a dot Statement
Param | Type | Description |
---|---|---|
document |
| Document which is being accessed. |
field |
| The field from which the document which is being accessed. |
value |
| The value for the document and field. |
Last updated