@@ -9,15 +9,49 @@ let WOQLQuery = require('./woqlCore')
99 }
1010}*/
1111
12- WOQLQuery . prototype . read_object = function ( IRI , OutputVar , Format ) {
13- //if (IRI && IRI == 'args') return ['document_uri', 'document']
12+ WOQLQuery . prototype . read_document = function ( IRI , OutputVar , Format ) {
1413 if ( this . cursor [ '@type' ] ) this . wrapCursorWithAnd ( )
15- this . cursor [ '@type' ] = 'ReadObject '
16- this . cursor [ 'document_uri ' ] = this . expandValueVariable ( IRI )
14+ this . cursor [ '@type' ] = 'ReadDocument '
15+ this . cursor [ 'identifier ' ] = this . cleanNodeValue ( IRI )
1716 this . cursor [ 'document' ] = this . expandValueVariable ( OutputVar )
1817 return this . wform ( Format )
1918}
2019
20+ WOQLQuery . prototype . insert_document = function ( docjson , IRI ) {
21+ if ( this . cursor [ '@type' ] ) this . wrapCursorWithAnd ( )
22+ this . cursor [ '@type' ] = 'InsertDocument'
23+ if ( typeof IRI !== 'undefined' ) this . cursor [ 'identifier' ] = this . cleanNodeValue ( IRI )
24+
25+ if ( typeof docjson === 'string' ) {
26+ this . cursor [ 'document' ] = this . expandValueVariable ( docjson ) ;
27+ } else {
28+ this . cursor [ 'document' ] = docjson ;
29+ }
30+
31+ return this . updated ( )
32+ }
33+
34+ WOQLQuery . prototype . update_document = function ( docjson , IRI ) {
35+ if ( this . cursor [ '@type' ] ) this . wrapCursorWithAnd ( )
36+ this . cursor [ '@type' ] = 'UpdateDocument'
37+ if ( typeof IRI !== 'undefined' ) this . cursor [ 'identifier' ] = this . cleanNodeValue ( IRI )
38+
39+ if ( typeof docjson === 'string' ) {
40+ this . cursor [ 'document' ] = this . expandValueVariable ( docjson ) ;
41+ } else {
42+ this . cursor [ 'document' ] = docjson ;
43+ }
44+
45+ return this . updated ( )
46+ }
47+
48+ WOQLQuery . prototype . delete_document = function ( IRI ) {
49+ if ( this . cursor [ '@type' ] ) this . wrapCursorWithAnd ( )
50+ this . cursor [ '@type' ] = 'DeleteDocument'
51+ this . cursor [ 'identifier' ] = this . cleanNodeValue ( IRI )
52+ return this . updated ( )
53+ }
54+
2155/**
2256 * Contains definitions of the WOQL functions which map directly to JSON-LD types
2357 * All other calls and queries can be composed from these
@@ -39,14 +73,6 @@ WOQLQuery.prototype.wrapCursorWithAnd = function() {
3973 }
4074}
4175
42- WOQLQuery . prototype . read_object = function ( IRI , OutputVar , Format ) {
43- //if (IRI && IRI == 'args') return ['document_uri', 'document']
44- if ( this . cursor [ '@type' ] ) this . wrapCursorWithAnd ( )
45- this . cursor [ '@type' ] = 'ReadObject'
46- this . cursor [ 'document_uri' ] = this . expandValueVariable ( IRI )
47- this . cursor [ 'document' ] = this . expandValueVariable ( OutputVar )
48- return this . wform ( Format )
49- }
5076
5177WOQLQuery . prototype . using = function ( Collection , Subq ) {
5278 //if (Collection && Collection == 'args')
0 commit comments