Comparing version 1.6.0 to 1.7.0
@@ -13,4 +13,6 @@ /*jshint browserify: true */ | ||
'into', | ||
'new', | ||
'let', | ||
'limit', | ||
'old', | ||
'null', | ||
@@ -17,0 +19,0 @@ 'remove', |
{ | ||
"name": "aqb", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "ArangoDB AQL query builder.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -469,2 +469,6 @@ # ArangoDB Query Builder | ||
### COLLECT varname1 = expression KEEP varname2 | ||
`PartialStatement::collect(varname1, expression).keep(varname2) : Statement` | ||
### SORT args… | ||
@@ -493,2 +497,6 @@ | ||
### REMOVE … LET varname = OLD RETURN varname | ||
`RemoveExpression::returnOld(varname) : Statement` | ||
### REMOVE … OPTIONS options | ||
@@ -511,2 +519,6 @@ | ||
### INSERT … LET varname = NEW RETURN varname | ||
`InsertExpression::returnNew(varname) : Statement` | ||
### UPDATE expression1 WITH expression2 IN collection | ||
@@ -537,2 +549,10 @@ | ||
### UPDATE … LET varname = NEW RETURN varname | ||
`UpdateExpression::returnNew(varname) : Statement` | ||
### UPDATE … LET varname = OLD RETURN varname | ||
`UpdateExpression::returnOld(varname) : Statement` | ||
### REPLACE expression1 WITH expression2 IN collection | ||
@@ -563,4 +583,12 @@ | ||
### REPLACE … LET varname = NEW RETURN varname | ||
`ReplaceExpression::returnOld(varname) : Statement` | ||
### REPLACE … LET varname = OLD RETURN varname | ||
`ReplaceExpression::returnNew(varname) : Statement` | ||
# License | ||
The Apache License, Version 2.0. For more information, see the accompanying LICENSE file. |
64
types.js
@@ -657,17 +657,16 @@ /*jshint browserify: true */ | ||
function RemoveExpression(prev, expr, collection) { | ||
function LetReturnExpression(prev, varname, keyword) { | ||
this.prev = prev; | ||
this.expr = autoCastToken(expr); | ||
this.collection = new Identifier(collection); | ||
this.varname = new Identifier(varname); | ||
this.keyword = new Keyword(keyword); | ||
if (['NEW', 'OLD'].indexOf(this.keyword.toAQL()) === -1) { | ||
throw new AqlError('Keyword must be "NEW" or "OLD"'); | ||
} | ||
} | ||
RemoveExpression.prototype = new Statement(); | ||
RemoveExpression.prototype.constructor = RemoveExpression; | ||
RemoveExpression.prototype.options = function (opts) { | ||
return new OptionsExpression(this, opts); | ||
}; | ||
RemoveExpression.prototype.toAQL = function () { | ||
LetReturnExpression.prototype = new Statement(); | ||
LetReturnExpression.prototype.toAQL = function () { | ||
return ( | ||
(this.prev ? this.prev.toAQL() + ' ' : '') + | ||
'REMOVE ' + wrapAQL(this.expr) + | ||
' IN ' + wrapAQL(this.collection) | ||
'LET ' + wrapAQL(this.varname) + ' = ' + wrapAQL(this.keyword) + ' ' + | ||
'RETURN ' + wrapAQL(this.varname) | ||
); | ||
@@ -682,2 +681,8 @@ }; | ||
OptionsExpression.prototype.constructor = OptionsExpression; | ||
OptionsExpression.prototype.returnOld = function (varname) { | ||
return new LetReturnExpression(this, varname, 'OLD'); | ||
}; | ||
OptionsExpression.prototype.returnNew = function (varname) { | ||
return new LetReturnExpression(this, varname, 'NEW'); | ||
}; | ||
OptionsExpression.prototype.toAQL = function () { | ||
@@ -690,2 +695,21 @@ return ( | ||
function RemoveExpression(prev, expr, collection) { | ||
this.prev = prev; | ||
this.expr = autoCastToken(expr); | ||
this.collection = new Identifier(collection); | ||
} | ||
RemoveExpression.prototype = new Statement(); | ||
RemoveExpression.prototype.constructor = RemoveExpression; | ||
RemoveExpression.prototype.options = function (opts) { | ||
return new OptionsExpression(this, opts); | ||
}; | ||
RemoveExpression.prototype.returnOld = OptionsExpression.prototype.returnOld; | ||
RemoveExpression.prototype.toAQL = function () { | ||
return ( | ||
(this.prev ? this.prev.toAQL() + ' ' : '') + | ||
'REMOVE ' + wrapAQL(this.expr) + | ||
' IN ' + wrapAQL(this.collection) | ||
); | ||
}; | ||
function InsertExpression(prev, expr, collection) { | ||
@@ -698,5 +722,4 @@ this.prev = prev; | ||
InsertExpression.prototype.constructor = InsertExpression; | ||
InsertExpression.prototype.options = function (opts) { | ||
return new OptionsExpression(this, opts); | ||
}; | ||
InsertExpression.prototype.options = RemoveExpression.prototype.options; | ||
InsertExpression.prototype.returnNew = OptionsExpression.prototype.returnNew; | ||
InsertExpression.prototype.toAQL = function () { | ||
@@ -718,5 +741,5 @@ return ( | ||
UpdateExpression.prototype.constructor = UpdateExpression; | ||
UpdateExpression.prototype.options = function (opts) { | ||
return new OptionsExpression(this, opts); | ||
}; | ||
UpdateExpression.prototype.options = RemoveExpression.prototype.options; | ||
UpdateExpression.prototype.returnOld = OptionsExpression.prototype.returnOld; | ||
UpdateExpression.prototype.returnNew = OptionsExpression.prototype.returnNew; | ||
UpdateExpression.prototype.toAQL = function () { | ||
@@ -739,5 +762,5 @@ return ( | ||
ReplaceExpression.prototype.constructor = ReplaceExpression; | ||
ReplaceExpression.prototype.options = function (opts) { | ||
return new OptionsExpression(this, opts); | ||
}; | ||
ReplaceExpression.prototype.options = RemoveExpression.prototype.options; | ||
ReplaceExpression.prototype.returnOld = OptionsExpression.prototype.returnOld; | ||
ReplaceExpression.prototype.returnNew = OptionsExpression.prototype.returnNew; | ||
ReplaceExpression.prototype.toAQL = function () { | ||
@@ -788,2 +811,3 @@ return ( | ||
exports._Definitions = Definitions; | ||
exports._LetReturnExpression = LetReturnExpression; | ||
exports._CollectIntoExpression = CollectIntoExpression; | ||
@@ -790,0 +814,0 @@ exports._CollectCountExpression = CollectCountExpression; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62503
953
590