Comparing version 7.14.0 to 7.15.0
@@ -34,2 +34,11 @@ 'use strict'; | ||
internals.empty = function (path) { | ||
const selector = path.reduce((memo, next) => memo(next), exports.row); | ||
return RethinkDB.branch( | ||
selector.typeOf().eq('ARRAY'), selector.isEmpty(), | ||
selector.typeOf().eq('OBJECT'), selector.keys().isEmpty(), | ||
false); | ||
}; | ||
internals.compile = function (criteria, relative) { | ||
@@ -63,5 +72,4 @@ | ||
// Special rule | ||
Hoek.assert(['contains', 'is', 'not', 'or', 'unset', 'empty'].indexOf(value.type) !== -1, `Unknown criteria value type ${value.type}`); | ||
Hoek.assert(['contains', 'is', 'not', 'or', 'unset'].indexOf(value.type) !== -1, `Unknown criteria value type ${value.type}`); | ||
if (value.type === 'contains') { | ||
@@ -97,6 +105,9 @@ | ||
if (typeof orValue === 'function') { | ||
Hoek.assert(['unset', 'is'].indexOf(orValue.type) !== -1, `Unknown or criteria value type ${orValue.type}`); | ||
Hoek.assert(['unset', 'is', 'empty'].indexOf(orValue.type) !== -1, `Unknown or criteria value type ${orValue.type}`); | ||
if (orValue.type === 'unset') { | ||
ors.push(exports.row(path.slice(0, -1)).hasFields(path[path.length - 1]).not()); | ||
} | ||
else if (orValue.type === 'empty') { | ||
ors.push(internals.empty(path)); | ||
} | ||
else { | ||
@@ -127,2 +138,8 @@ ors.push(internals.toComparator(row, orValue)); | ||
} | ||
else if (value.type === 'empty') { | ||
// empty | ||
tests.push(internals.empty(path)); | ||
} | ||
else { | ||
@@ -129,0 +146,0 @@ |
@@ -648,2 +648,7 @@ 'use strict'; | ||
static empty() { | ||
return internals.special('empty'); | ||
} | ||
// Criteria or Modifier | ||
@@ -679,2 +684,3 @@ | ||
internals.Db.prototype.unset = internals.Db.unset; | ||
internals.Db.prototype.empty = internals.Db.empty; | ||
internals.Db.prototype.increment = internals.Db.increment; | ||
@@ -681,0 +687,0 @@ internals.Db.prototype.append = internals.Db.append; |
{ | ||
"name": "penseur", | ||
"description": "Lightweight RethinkDB wrapper", | ||
"version": "7.14.0", | ||
"version": "7.15.0", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/hueniverse/penseur", |
@@ -210,2 +210,3 @@ # penseur | ||
#### `Db.unset()` | ||
#### `Db.empty()` | ||
#### `Db.increment(value)` | ||
@@ -212,0 +213,0 @@ #### `Db.append(value[, options])` |
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
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
77307
1783
216