Skip to content

Commit 82d8009

Browse files
added dot query in woql (#81)
1 parent 6713a75 commit 82d8009

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
- [update_quad](api/woql.js?id=update_quad)
152152
- [value](api/woql.js?id=value)
153153
- [link](api/woql.js?id=link)
154+
- [dot](api/woql.js?id=dot)
154155
- [WOQLLibrary](api/woqlLibrary.js?id=WOQLLibrary)
155156
- [branches](api/woqlLibrary.js?id=branches)
156157
- [commits](api/woqlLibrary.js?id=commits)

docs/api/woql.js.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,3 +1417,16 @@ Creates a pattern matching rule for a quad [Subject, Predicate, Object, Graph] o
14171417
| object | <code>string</code> | The IRI of a node or a variable, or a literal |
14181418
| [graphRef] | <code>typedef.GraphRef</code> | specify a graph type, default is instance schema|instance |
14191419

1420+
1421+
### dot
1422+
#### WOQL.dot(document, field, value) ⇒ <code>WOQLQuery</code>
1423+
Extract the value of a key in a bound document.
1424+
1425+
**Returns**: <code>WOQLQuery</code> - A WOQLQuery which contains the a dot Statement
1426+
1427+
| Param | Type | Description |
1428+
| --- | --- | --- |
1429+
| document | <code>string</code> | Document which is being accessed. |
1430+
| field | <code>string</code> | The field from which the document which is being accessed. |
1431+
| value | <code>string</code> | The value for the document and field. |
1432+

lib/query/woqlQuery.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,15 @@ WOQLQuery.prototype.path = function(Subject, Pattern, Object, Path) {
971971
return this
972972
}
973973

974+
WOQLQuery.prototype.dot = function(Document, Field, Value) {
975+
if (this.cursor['@type']) this.wrapCursorWithAnd()
976+
this.cursor['@type'] = 'Dot'
977+
this.cursor['document'] = this.expandValueVariable(Document)
978+
this.cursor['field'] = this.cleanDataValue(Field, 'xsd:string')
979+
this.cursor['value'] = this.expandValueVariable(Value)
980+
return this
981+
}
982+
974983
WOQLQuery.prototype.size = function(Graph, Size) {
975984
//if (Graph && Graph == 'args')
976985
//return ['resource', 'size']

lib/woql.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,5 +1279,15 @@ WOQL.link = function(subject, predicate, object, graphRef) {
12791279
return new WOQLQuery().link(subject, predicate, object, graphRef)
12801280
}
12811281

1282+
/**
1283+
* Extract the value of a key in a bound document.
1284+
* @param {string} document - Document which is being accessed.
1285+
* @param {string} field - The field from which the document which is being accessed.
1286+
* @param {string} value - The value for the document and field.
1287+
* @returns {WOQLQuery} A WOQLQuery which contains the a dot Statement
1288+
*/
1289+
WOQL.dot = function(document, field, value) {
1290+
return new WOQLQuery().dot(document, field, value);
1291+
}
12821292

12831293
module.exports = WOQL

0 commit comments

Comments
 (0)