Comparing version 8.4.1 to 8.5.0
@@ -8,3 +8,5 @@ 'use strict'; | ||
const Geo = require('./geo'); | ||
// Declare internals | ||
@@ -31,3 +33,5 @@ | ||
return table.raw.filter(internals.compile(criteria, null, options)); | ||
const base = (table._geo ? Geo.select(criteria, table) : table.raw); | ||
const filter = internals.compile(criteria, null, options); | ||
return (filter ? base.filter(filter) : base); | ||
}; | ||
@@ -71,2 +75,6 @@ | ||
if (value.type === 'near') { | ||
continue; | ||
} | ||
Hoek.assert(['contains', 'is', 'not', 'or', 'unset', 'empty', 'match'].indexOf(value.type) !== -1, `Unknown criteria value type ${value.type}`); | ||
@@ -166,2 +174,6 @@ | ||
if (!tests.length) { | ||
return null; | ||
} | ||
criteria = (tests.length === 1 ? tests[0] : RethinkDB.and.apply(RethinkDB, tests)); | ||
@@ -168,0 +180,0 @@ |
@@ -101,3 +101,4 @@ 'use strict'; | ||
unique: Joi.array().items(internals.unique).min(1).single(), | ||
primary: Joi.string().max(127) | ||
primary: Joi.string().max(127), | ||
geo: Joi.boolean().default(false) | ||
}) | ||
@@ -499,2 +500,7 @@ .allow(true, false) | ||
static near(coordinates, distance, unit) { | ||
return internals.special('near', coordinates, { distance, unit }); | ||
} | ||
static not(values) { | ||
@@ -573,2 +579,3 @@ | ||
internals.Db.prototype.match = internals.Db.match; | ||
internals.Db.prototype.near = internals.Db.near; | ||
internals.Db.prototype.not = internals.Db.not; | ||
@@ -575,0 +582,0 @@ internals.Db.prototype.or = internals.Db.or; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -11,2 +11,3 @@ 'use strict'; | ||
const Criteria = require('./criteria'); | ||
const Geo = require('./geo'); | ||
const Id = require('./id'); | ||
@@ -39,2 +40,3 @@ const Modifier = require('./modifier'); | ||
this._unique = Unique.compile(this, options.unique); | ||
this._geo = Geo.index(options); | ||
@@ -53,3 +55,4 @@ this.raw = RethinkDB.db(this._db.name).table(name); | ||
const query = (batch ? this.raw.getAll(RethinkDB.args(ids)) : this.raw.get(ids)); | ||
return await this._db._run(this._refine(query, options), track); | ||
const items = await this._db._run(this._refine(query, options), track); | ||
return this._read(items); | ||
} | ||
@@ -94,3 +97,4 @@ catch (err) { | ||
try { | ||
return await this._db._run(this._refine(this.raw, options, true), track); | ||
const items = await this._db._run(this._refine(this.raw, options, true), track); | ||
return this._read(items); | ||
} | ||
@@ -150,3 +154,4 @@ catch (err) { | ||
const selection = Criteria.select(criteria, this, options); | ||
return await this._db._run(this._refine(selection, options), track); | ||
const items = await this._db._run(this._refine(selection, options), track); | ||
return this._read(items); | ||
} | ||
@@ -172,3 +177,3 @@ catch (err) { | ||
return result[0]; | ||
return this._read(result[0]); | ||
} | ||
@@ -230,3 +235,3 @@ catch (err) { | ||
try { | ||
const wrapped = await Id.wrap(this, items); | ||
const wrapped = await Id.wrap(this, this._write(items)); | ||
const postUnique = await Unique.reserve(this, wrapped, options.merge === true); | ||
@@ -548,4 +553,4 @@ | ||
type, | ||
before: item.old_val || null, | ||
after: item.new_val || null | ||
before: this._read(item.old_val) || null, | ||
after: this._read(item.new_val) || null | ||
}; | ||
@@ -581,2 +586,20 @@ | ||
_read(items) { | ||
if (this._geo) { | ||
Geo.read(items, this); | ||
} | ||
return items; | ||
} | ||
_write(items) { | ||
if (this._geo) { | ||
Geo.write(items, this); | ||
} | ||
return items; | ||
} | ||
static error(err, { table, action, inputs }, flags) { | ||
@@ -583,0 +606,0 @@ |
@@ -0,0 +0,0 @@ 'use strict'; |
{ | ||
"name": "penseur", | ||
"description": "Lightweight RethinkDB wrapper", | ||
"version": "8.4.1", | ||
"version": "8.5.0", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/hueniverse/penseur", |
@@ -0,0 +0,0 @@ # penseur |
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
72847
14
1792