diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 4e695277..3677994d 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -148,6 +148,7 @@ - [update_quad](api/woql.js?id=update_quad) - [value](api/woql.js?id=value) - [link](api/woql.js?id=link) + - [dot](api/woql.js?id=dot) - [WOQLLibrary](api/woqlLibrary.js?id=WOQLLibrary) - [branches](api/woqlLibrary.js?id=branches) - [commits](api/woqlLibrary.js?id=commits) diff --git a/docs/api/woql.js.md b/docs/api/woql.js.md index a04ba573..bc157672 100644 --- a/docs/api/woql.js.md +++ b/docs/api/woql.js.md @@ -1375,3 +1375,16 @@ Creates a pattern matching rule for a quad [Subject, Predicate, Object, Graph] o | object | string | The IRI of a node or a variable, or a literal | | [graphRef] | typedef.GraphRef | specify a graph type, default is instance schema|instance | + +### 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 | string | Document which is being accessed. | +| field | string | The field from which the document which is being accessed. | +| value | string | The value for the document and field. | + diff --git a/lib/query/woqlQuery.js b/lib/query/woqlQuery.js index a2c2ac81..fd864605 100644 --- a/lib/query/woqlQuery.js +++ b/lib/query/woqlQuery.js @@ -943,6 +943,15 @@ WOQLQuery.prototype.path = function(Subject, Pattern, Object, Path) { return this } +WOQLQuery.prototype.dot = function(Document, Field, Value) { + if (this.cursor['@type']) this.wrapCursorWithAnd() + this.cursor['@type'] = 'Dot' + this.cursor['document'] = this.expandValueVariable(Document) + this.cursor['field'] = this.cleanDataValue(Field, 'xsd:string') + this.cursor['value'] = this.expandValueVariable(Value) + return this +} + WOQLQuery.prototype.size = function(Graph, Size) { //if (Graph && Graph == 'args') //return ['resource', 'size'] diff --git a/lib/woql.js b/lib/woql.js index 93632000..6877d398 100644 --- a/lib/woql.js +++ b/lib/woql.js @@ -1242,5 +1242,15 @@ WOQL.link = function(subject, predicate, object, graphRef) { return new WOQLQuery().link(subject, predicate, object, graphRef) } +/** + * Extract the value of a key in a bound document. + * @param {string} document - Document which is being accessed. + * @param {string} field - The field from which the document which is being accessed. + * @param {string} value - The value for the document and field. + * @returns {WOQLQuery} A WOQLQuery which contains the a dot Statement + */ + WOQL.dot = function(document, field, value) { + return new WOQLQuery().dot(document, field, value); +} module.exports = WOQL