mirror of https://gitee.com/bigwinds/arangodb
Also accept `false` instead of an empty array.
This commit is contained in:
parent
382747add9
commit
7a4076da8f
|
@ -139,7 +139,7 @@ Using a transformation with extra arguments (and no query parameters):
|
|||
```js
|
||||
var query = Foxx.createQuery({
|
||||
query: 'FOR u IN _users SORT u.user ASC RETURN u.user',
|
||||
params: [],
|
||||
params: false, // an empty array would work, too
|
||||
transform: function (results, uppercase) {
|
||||
return uppercase ? results[0].toUpperCase() : results[0].toLowerCase();
|
||||
}
|
||||
|
|
|
@ -46,12 +46,14 @@ exports.createQuery = function createQuery (cfg) {
|
|||
defaults = cfg.defaults,
|
||||
transform = cfg.transform;
|
||||
|
||||
if (params && !Array.isArray(params)) {
|
||||
if (params === false) {
|
||||
params = [];
|
||||
} else if (params && !Array.isArray(params)) {
|
||||
params = [params];
|
||||
}
|
||||
|
||||
if (params && !params.each(function (v) {return typeof v === 'string';})) {
|
||||
throw new Error('Argument names must be a string or an array of strings.');
|
||||
throw new Error('Argument names must be a string, an array of strings or false.');
|
||||
}
|
||||
|
||||
if (!query || (typeof query !== 'string' && typeof query.toAQL !== 'function')) {
|
||||
|
|
Loading…
Reference in New Issue