@@ -16,7 +16,9 @@ const WOQL = {};
16
16
WOQL . when = function ( Query , Update ) { return new WOQLQuery ( ) . when ( Query , Update ) ; }
17
17
WOQL . opt = function ( query ) { return new WOQLQuery ( ) . opt ( query ) ; }
18
18
WOQL . from = function ( dburl , query ) { return new WOQLQuery ( ) . from ( dburl , query ) ; }
19
+ WOQL . into = function ( dburl , query ) { return new WOQLQuery ( ) . into ( dburl , query ) ; }
19
20
WOQL . limit = function ( limit , query ) { return new WOQLQuery ( ) . limit ( limit , query ) ; }
21
+ WOQL . start = function ( start , query ) { return new WOQLQuery ( ) . start ( limit , query ) ; }
20
22
WOQL . select = function ( ...list ) { return new WOQLQuery ( ) . select ( ...list ) ; }
21
23
WOQL . or = function ( ...queries ) { return new WOQLQuery ( ) . or ( ...queries ) ; }
22
24
WOQL . and = function ( ...queries ) { return new WOQLQuery ( ) . and ( ...queries ) ; }
@@ -188,14 +190,20 @@ WOQLQuery.prototype.json = function(json){
188
190
* into the corrent place in the encompassing json
189
191
*/
190
192
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 ) ;
195
199
}
196
- this . advanceCursor ( "when" , Query ) ;
197
200
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 ] ;
199
207
}
200
208
return this ;
201
209
}
@@ -220,6 +228,15 @@ WOQLQuery.prototype.from = function(dburl, query){
220
228
return this ;
221
229
}
222
230
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
+
223
240
WOQLQuery . prototype . limit = function ( limit , query ) {
224
241
this . advanceCursor ( "limit" , limit ) ;
225
242
if ( query ) {
@@ -804,6 +821,14 @@ WOQLQuery.prototype.setStart = function(start){
804
821
return this . setPagingProperty ( "start" , start ) ;
805
822
}
806
823
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
+
807
832
/**
808
833
* Executes the query using the passed client to connect to a server
809
834
*/
0 commit comments