pouchdb-selector-core
Advanced tools
Comparing version 6.2.0 to 6.2.1-prerelease
@@ -304,6 +304,2 @@ import { clone } from 'pouchdb-utils'; | ||
return inMemoryFields.every(function (field) { | ||
if (isDesignDoc(doc)) { | ||
return false; | ||
} | ||
var matcher = selector[field]; | ||
@@ -320,6 +316,2 @@ var parsedField = parseField(field); | ||
function isDesignDoc(doc) { | ||
return /^_design\//.test(doc._id); | ||
} | ||
function matchSelector(matcher, doc, parsedField, docFieldValue) { | ||
@@ -360,3 +352,3 @@ if (!matcher) { | ||
'" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, ' + | ||
'$nin, $size, $mod, $regex, $elemMatch, $type or $all'); | ||
'$nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all'); | ||
} | ||
@@ -466,2 +458,23 @@ return matchers[userOperator](doc, userValue, parsedField, docFieldValue); | ||
'$allMatch': function (doc, userValue, parsedField, docFieldValue) { | ||
if (!Array.isArray(docFieldValue)) { | ||
return false; | ||
} | ||
/* istanbul ignore next */ | ||
if (docFieldValue.length === 0) { | ||
return false; | ||
} | ||
if (typeof docFieldValue[0] === 'object') { | ||
return docFieldValue.every(function (val) { | ||
return rowFilter(val, userValue, Object.keys(userValue)); | ||
}); | ||
} | ||
return docFieldValue.every(function (val) { | ||
return matchSelector(userValue, doc, parsedField, val); | ||
}); | ||
}, | ||
'$eq': function (doc, userValue, parsedField, docFieldValue) { | ||
@@ -535,3 +548,3 @@ return fieldIsNotUndefined(docFieldValue) && collate(docFieldValue, userValue) === 0; | ||
// match the CouchDB error message | ||
throw 'Selector error: expected a JSON object'; | ||
throw new Error('Selector error: expected a JSON object'); | ||
} | ||
@@ -538,0 +551,0 @@ |
@@ -308,6 +308,2 @@ 'use strict'; | ||
return inMemoryFields.every(function (field) { | ||
if (isDesignDoc(doc)) { | ||
return false; | ||
} | ||
var matcher = selector[field]; | ||
@@ -324,6 +320,2 @@ var parsedField = parseField(field); | ||
function isDesignDoc(doc) { | ||
return /^_design\//.test(doc._id); | ||
} | ||
function matchSelector(matcher, doc, parsedField, docFieldValue) { | ||
@@ -364,3 +356,3 @@ if (!matcher) { | ||
'" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, ' + | ||
'$nin, $size, $mod, $regex, $elemMatch, $type or $all'); | ||
'$nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all'); | ||
} | ||
@@ -470,2 +462,23 @@ return matchers[userOperator](doc, userValue, parsedField, docFieldValue); | ||
'$allMatch': function (doc, userValue, parsedField, docFieldValue) { | ||
if (!Array.isArray(docFieldValue)) { | ||
return false; | ||
} | ||
/* istanbul ignore next */ | ||
if (docFieldValue.length === 0) { | ||
return false; | ||
} | ||
if (typeof docFieldValue[0] === 'object') { | ||
return docFieldValue.every(function (val) { | ||
return rowFilter(val, userValue, Object.keys(userValue)); | ||
}); | ||
} | ||
return docFieldValue.every(function (val) { | ||
return matchSelector(userValue, doc, parsedField, val); | ||
}); | ||
}, | ||
'$eq': function (doc, userValue, parsedField, docFieldValue) { | ||
@@ -539,3 +552,3 @@ return fieldIsNotUndefined(docFieldValue) && pouchdbCollate.collate(docFieldValue, userValue) === 0; | ||
// match the CouchDB error message | ||
throw 'Selector error: expected a JSON object'; | ||
throw new Error('Selector error: expected a JSON object'); | ||
} | ||
@@ -542,0 +555,0 @@ |
{ | ||
"name": "pouchdb-selector-core", | ||
"version": "6.2.0", | ||
"version": "6.2.1-prerelease", | ||
"description": "PouchDB's core selector code", | ||
@@ -10,12 +10,3 @@ "main": "./lib/index.js", | ||
"repository": "https://github.com/pouchdb/pouchdb", | ||
"jsnext:main": "./lib/index.es.js", | ||
"dependencies": { | ||
"pouchdb-collate": "6.2.0", | ||
"pouchdb-utils": "6.2.0" | ||
}, | ||
"files": [ | ||
"lib", | ||
"dist", | ||
"tonic-example.js" | ||
] | ||
"jsnext:main": "./src/index.js" | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
62477
0
9
1463
1
2
- Removedpouchdb-collate@6.2.0
- Removedpouchdb-utils@6.2.0
- Removedargsarray@0.0.1(transitive)
- Removedclone-buffer@1.0.0(transitive)
- Removedimmediate@3.0.6(transitive)
- Removedinherits@2.0.3(transitive)
- Removedlie@3.1.1(transitive)
- Removedpouchdb-collate@6.2.0(transitive)
- Removedpouchdb-collections@6.2.0(transitive)
- Removedpouchdb-errors@6.2.0(transitive)
- Removedpouchdb-promise@6.2.0(transitive)
- Removedpouchdb-utils@6.2.0(transitive)