Skip to content

Commit e396905

Browse files
committed
Merge branch 'dev' of https://github.com/terminusdb/terminus-client into dev
2 parents 524a137 + 9ed3f6f commit e396905

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

lib/woql.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const WOQL = {};
1616
WOQL.when = function(Query, Update){ return new WOQLQuery().when(Query, Update);}
1717
WOQL.opt = function(query){ return new WOQLQuery().opt(query); }
1818
WOQL.from = function(dburl, query){ return new WOQLQuery().from(dburl, query); }
19+
WOQL.into = function(dburl, query){ return new WOQLQuery().into(dburl, query); }
1920
WOQL.limit = function(limit, query){ return new WOQLQuery().limit(limit, query); }
21+
WOQL.start = function(start, query){ return new WOQLQuery().start(limit, query); }
2022
WOQL.select = function(...list){ return new WOQLQuery().select(...list); }
2123
WOQL.or = function(...queries){ return new WOQLQuery().or(...queries); }
2224
WOQL.and = function(...queries){ return new WOQLQuery().and(...queries); }
@@ -188,14 +190,20 @@ WOQLQuery.prototype.json = function(json){
188190
* into the corrent place in the encompassing json
189191
*/
190192
WOQLQuery.prototype.when = function(Query, Update){
191-
if(typeof Query == "boolean") {
192-
var jq = {};
193-
jq[Query] = [];
194-
Query = jq;
193+
if(typeof Query == 'boolean'){
194+
this.cursor["when"] = [Query];
195+
}
196+
else {
197+
var q = (q.json ? q.json() : q);
198+
this.advanceCursor("when", q);
195199
}
196-
this.advanceCursor("when", Query);
197200
if(Update){
198-
this.cursor = (Update.json ? Update.json() : Update);
201+
var upd = (Update.json ? Update.json() : Update);
202+
this.cursor["when"][1] = upd;
203+
}
204+
else {
205+
this.cursor["when"][1] = {};
206+
this.cursor = this.cursor["when"][1];
199207
}
200208
return this;
201209
}
@@ -220,6 +228,15 @@ WOQLQuery.prototype.from = function(dburl, query){
220228
return this;
221229
}
222230

231+
WOQLQuery.prototype.into = function(dburl, query){
232+
this.advanceCursor("into", dburl);
233+
if(query){
234+
this.cursor = query.json();
235+
}
236+
return this;
237+
}
238+
239+
223240
WOQLQuery.prototype.limit = function(limit, query){
224241
this.advanceCursor("limit", limit);
225242
if(query){
@@ -804,6 +821,14 @@ WOQLQuery.prototype.setStart = function(start){
804821
return this.setPagingProperty("start", start);
805822
}
806823

824+
WOQLQuery.prototype.addStart = function(s){
825+
if(this.hasStart("start")) this.setStart(s);
826+
var nq = {'start': [s, this.query]};
827+
this.query = nq;
828+
return this;
829+
}
830+
831+
807832
/**
808833
* Executes the query using the passed client to connect to a server
809834
*/

0 commit comments

Comments
 (0)