Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "aqb", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "ArangoDB AQL query builder.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -562,5 +562,5 @@ # ArangoDB Query Builder | ||
Creates a function call for the given name and arguments. | ||
Creates a functon call for the given name and arguments. | ||
`qb.fn(name)(args…)` | ||
`qb.fn(name)(...args)` | ||
@@ -685,9 +685,9 @@ If the values are not already AQL values, they will be converted automatically. | ||
##### … KEEP | ||
##### … KEEP ...vars | ||
`CollectExpression::keep() : CollectExpression` | ||
`CollectExpression::keep(...vars) : CollectExpression` | ||
**Examples** | ||
* `_.into('z').keep()` => `INTO z KEEP` | ||
* `_.into('z').keep('a', 'b')` => `INTO z KEEP a, b` | ||
@@ -710,5 +710,5 @@ #### … INTO varname = expression | ||
### … SORT args… | ||
### … SORT ...args | ||
`PartialStatement::sort(args…) : PartialStatement` | ||
`PartialStatement::sort(...args) : PartialStatement` | ||
@@ -715,0 +715,0 @@ **Examples** |
27
types.js
@@ -664,3 +664,3 @@ /*jshint browserify: true */ | ||
function CollectExpression(prev, dfns, varname, intoExpr, keep, options) { | ||
function CollectExpression(prev, dfns, varname, intoExpr, keepNames, options) { | ||
this._prev = prev; | ||
@@ -675,7 +675,18 @@ this._dfns = new Definitions(dfns); | ||
this._varname = new Identifier(varname); | ||
if (!keep) { | ||
if (!keepNames) { | ||
this.keep = function () { | ||
return new CollectExpression(prev, dfns, varname, undefined, true, options); | ||
var newKeepNames = Array.prototype.slice.call(arguments); | ||
return new CollectExpression(prev, dfns, varname, undefined, newKeepNames, options); | ||
}; | ||
} else this._keep = true; | ||
} else { | ||
if (!Array.isArray(keepNames)) { | ||
throw new AqlError('Expected keep list to be an array: ' + keepNames); | ||
} | ||
if (!keepNames.length) { | ||
throw new AqlError('Expected keep list not to be empty: ' + keepNames); | ||
} | ||
this._keep = keepNames.map(function (keepVar) { | ||
return new Identifier(keepVar); | ||
}); | ||
} | ||
} | ||
@@ -688,6 +699,6 @@ } else if (varname) { | ||
this.options = function (newOpts) { | ||
return new CollectExpression(prev, dfns, varname, intoExpr, keep, newOpts); | ||
return new CollectExpression(prev, dfns, varname, intoExpr, keepNames, newOpts); | ||
}; | ||
} else this._options = new ObjectLiteral(options); | ||
if (!varname && !intoExpr && !keep) { | ||
if (!varname && !intoExpr && !keepNames) { | ||
this.withCountInto = function (newVarname) { | ||
@@ -706,3 +717,5 @@ return new CollectWithCountIntoExpression(prev, dfns, newVarname, options); | ||
this._intoExpr ? ' = ' + wrapAQL(this._intoExpr) : | ||
(this._keep ? ' KEEP' : '') | ||
(this._keep ? ' KEEP ' + this._keep.map(function (keep) { | ||
return keep.toAQL(); | ||
}).join(', ') : '') | ||
) : '') + | ||
@@ -709,0 +722,0 @@ (this._options ? ' OPTIONS ' + wrapAQL(this._options) : '') |
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
72376
1161