Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var opts = Object.assign({
include_docs: true,
reduce: false
}, queryPlan.queryOpts);
if ('startkey' in opts && 'endkey' in opts &&
collate(opts.startkey, opts.endkey) > 0) {
// can't possibly return any results, startkey > endkey
/* istanbul ignore next */
return {docs: []};
}
var isDescending = requestDef.sort &&
typeof requestDef.sort[0] !== 'string' &&
getValue(requestDef.sort[0]) === 'desc';
if (isDescending) {
// either all descending or all ascending
opts.descending = true;
opts = reverseOptions(opts);
}
if (!queryPlan.inMemoryFields.length) {
// no in-memory filtering necessary, so we can let the
// database do the limit/skip for us
if ('limit' in requestDef) {
opts.limit = requestDef.limit;
}
if ('skip' in requestDef) {
opts.skip = requestDef.skip;
}
var ascFields = index.fields.filter(function (field) {
return getValue(field) === 'asc';
});
if (ascFields.length !== 0 && ascFields.length !== index.fields.length) {