Specifies a Subject for the requested data, using variables to place-hold
variables matched by the @where
clause.
An optional JSON-LD Context for the query. Use of a query-specific Context is rarely required, as the context is typically the local application, whose needs are specified by the local clone configuration.
The data pattern to match, as a set of subjects or a group. Variables are used as placeholders to capture matching properties and values in the domain.
Match a subject by its @id
{
...
"@where": { "@id": "fred" }
}
Match a subject where any property has a given value
{
...
"@where": {
"@id": "?id",
"?prop": "Bedrock"
}
}
Match a subject with a given property, having any value
{
...
"@where": {
"@id": "?id",
"name": "?name"
}
}
The Javascript engine supports exact-matches for subject identities, properties and values. Inline filters will be available in future.
Generated using TypeDoc. Delivered by Vercel. @m-ld/m-ld - v0.8.2 Source code licensed MIT. Privacy policy
A query pattern that returns a specified JSON structure with variable substitutions. This is useful to query all information needed for some domain entity, including nested information.
The
@construct
member defines a JSON template, with placeholder variables for the data to be filled by the query. The returned subjects will have the given template structure, with a few exceptions:@list
contents are always returned as an array, even if the query uses an object (see examples).@id
. If no@id
is given in the template (as a fixed IRI or variable), a generated placeholder will be used (starting with_:
).A
@construct
can be used by itself as a straightforward pattern match to data already in the domain, or with a@where
clause to create new data structures.Examples:
Pattern match an identified subject with nested content
{ "@construct": { "@id": "fred", "children": { "@id": "?child", "name": "?childName" } } }
might return:
{ "@id": "fred", "children": [ { "@id": "pebbles", "name": "Pebbles" }, { "@id": "stony", "name": "Stony" } ] }
Pattern match list content
{ "@construct": { "@id": "fred", "appearsIn": { "@list": { "1": "?" } } } }
might return (note sparse array containing only the requested index):
{ "@id": "fred", "appearsIn": { "@list": [ null, { "@id": "hotLipsHannigan" } ] } }
Construct new information based on existing information
{ "@construct": { "@id": "?parent", "grandchildren": { "@id": "?grandchild" } }, "@where": { "@id": "?parent", "children": { "children": { "@id": "?grandchild" } } } }
might return:
{ "@id": "fred", "grandchildren": [ { "@id": "roxy" }, { "@id": "chip" } ] }
json-rql construct