1
0
Fork 0

Also accept `false` instead of an empty array.

This commit is contained in:
Alan Plum 2014-12-03 10:52:47 +01:00
parent 382747add9
commit 7a4076da8f
2 changed files with 5 additions and 3 deletions

View File

@ -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();
}

View File

@ -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')) {