matches-where-query
Advanced tools
Comparing version 2.0.5 to 2.0.6
@@ -51,2 +51,7 @@ "use strict"; | ||
break; | ||
case 'contains': | ||
if (!objectAttribute) return false; | ||
if (!_underscore["default"].isString(objectAttribute) && !_underscore["default"].isArray(objectAttribute)) return false; | ||
if (!objectAttribute.includes(queryAttribute.value)) return false; | ||
break; | ||
default: | ||
@@ -53,0 +58,0 @@ throw new Error('Invalid comparator ' + queryAttribute.comparator); |
{ | ||
"name": "matches-where-query", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"main": "lib/matchesWhereQuery.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -39,2 +39,13 @@ # matchesWhereQuery( object, whereQuery ) | ||
## contains | ||
The compared attribute must be a string that contains the provided value, or an array that has at least one element strictly equal to the provided value. | ||
``` | ||
{ | ||
<attribute> : { comparator : 'contains', value : <value> } | ||
} | ||
``` | ||
## doesNotEqual | ||
@@ -50,3 +61,3 @@ The compared attribute must must not be strictly equal to the value to result in a match. | ||
## isGreaterThan | ||
The compared attribute must be greater than the value to result in a match. | ||
The compared attribute must be greater than the value to result in a match. `NULL` values are automatically discarded. | ||
``` | ||
@@ -59,3 +70,3 @@ { | ||
## isGreaterThanOrEqualTo | ||
The compared attribute must be greater than or equal to the value to result in a match. | ||
The compared attribute must be greater than or equal to the value to result in a match. `NULL` values are automatically discarded. | ||
@@ -69,3 +80,3 @@ ``` | ||
## isLessThan | ||
The compared attribute must be less than the value to result in a match. | ||
The compared attribute must be less than the value to result in a match. `NULL` values are automatically discarded. | ||
@@ -79,3 +90,3 @@ ``` | ||
## isLessThanOrEqualTo | ||
The compared attribute must be less than or equal to the value to result in a match. | ||
The compared attribute must be less than or equal to the value to result in a match. `NULL` values are automatically discarded. | ||
``` | ||
@@ -88,3 +99,3 @@ { | ||
## isBetween | ||
The compared attribute must be between the minimum and maximum values provided to result in a match. The limits provided are included in the range for the value. | ||
The compared attribute must be between the minimum and maximum values provided to result in a match. The limits provided are included in the range for the value. `NULL` values are automatically discarded. | ||
@@ -98,3 +109,3 @@ ``` | ||
## startsWith | ||
The compared attribute must be a string that starts with the string value provided to result in a match. | ||
The compared attribute must be a string that starts with the string value provided to result in a match. `NULL` values are automatically discarded. | ||
@@ -108,3 +119,3 @@ ``` | ||
## endsWith | ||
The compared attribute must be a string that ends with the string value provided to result in a match. | ||
The compared attribute must be a string that ends with the string value provided to result in a match. `NULL` values are automatically discarded. | ||
@@ -111,0 +122,0 @@ ``` |
@@ -15,3 +15,4 @@ var _ = require( 'underscore' ); | ||
city : 'Buenos Aires', | ||
age : null | ||
age : null, | ||
permissions : [ 'read', 'write' ] | ||
}; | ||
@@ -238,2 +239,42 @@ } ); | ||
} ); | ||
describe( 'isNotNull', function() { | ||
it( 'Match', function() { | ||
var comparator = { firstName : { comparator : 'isNotNull' } }; | ||
expect( matchesWhereQuery( person, comparator ) ).to.be.true; | ||
} ); | ||
it( 'Not Match', function() { | ||
var comparator = { age : { comparator : 'isNotNull' } }; | ||
expect( matchesWhereQuery( person, comparator ) ).to.be.false; | ||
} ); | ||
} ); | ||
describe( 'contains', function() { | ||
it( 'Match - when string', function() { | ||
var comparator = { firstName : { comparator : 'contains', value : 'ar' } }; | ||
expect( matchesWhereQuery( person, comparator ) ).to.be.true; | ||
} ); | ||
it( 'Not Match - when string', function() { | ||
var comparator = { firstName : { comparator : 'contains', value : 'no' } }; | ||
expect( matchesWhereQuery( person, comparator ) ).to.be.false; | ||
} ); | ||
it( 'Match - when array', function() { | ||
var comparator = { permissions : { comparator : 'contains', value : 'read' } }; | ||
expect( matchesWhereQuery( person, comparator ) ).to.be.true; | ||
} ); | ||
it( 'Not Match - when string', function() { | ||
var comparator = { permissions : { comparator : 'contains', value : 'delete' } }; | ||
expect( matchesWhereQuery( person, comparator ) ).to.be.false; | ||
} ); | ||
} ); | ||
} ); |
Sorry, the diff of this file is not supported yet
20294
290
136