Comparing version 1.5.2 to 2.0.0
@@ -211,1 +211,7 @@ // Load Modules | ||
}; | ||
internals.Db.prototype.fields = function (criteria) { | ||
return new Table.Criteria(criteria, 'fields'); | ||
}; |
@@ -34,3 +34,3 @@ // Load Modules | ||
this._run(this._table.filter(criteria), 'query', criteria, callback); | ||
this._run(internals.wrap(criteria).select(this._table), 'query', criteria, callback); | ||
}; | ||
@@ -43,3 +43,3 @@ | ||
this._run(this._table.filter(criteria), 'single', criteria, callback, function (ignore, result) { | ||
this._run(internals.wrap(criteria).select(this._table), 'single', criteria, callback, function (ignore, result) { | ||
@@ -59,5 +59,5 @@ if (!result) { | ||
internals.Table.prototype.count = function (criteria, type, callback) { | ||
internals.Table.prototype.count = function (criteria, callback) { | ||
this._run(this._table[type === 'fields' ? 'hasFields' : 'filter'](criteria).count(), 'count', { criteria: criteria, type: type }, callback); | ||
this._run(internals.wrap(criteria).select(this._table).count(), 'count', { criteria: criteria }, callback); | ||
}; | ||
@@ -303,1 +303,24 @@ | ||
}; | ||
exports.Criteria = internals.Criteria = function (criteria, type) { | ||
this.criteria = criteria; | ||
this.type = type || 'filter'; | ||
}; | ||
internals.Criteria.prototype.select = function (table) { | ||
return table[this.type === 'fields' ? 'hasFields' : 'filter'](this.criteria); | ||
}; | ||
internals.wrap = function (criteria) { | ||
if (criteria instanceof internals.Criteria) { | ||
return criteria; | ||
} | ||
return new internals.Criteria(criteria); | ||
}; |
{ | ||
"name": "penseur", | ||
"description": "Lightweight RethinkDB wrapper", | ||
"version": "1.5.2", | ||
"version": "2.0.0", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/hueniverse/penseur", |
@@ -219,3 +219,3 @@ // Load modules | ||
db.test.count({ a: 1 }, 'filter', function (err, result) { | ||
db.test.count({ a: 1 }, function (err, result) { | ||
@@ -240,3 +240,3 @@ expect(err).to.not.exist(); | ||
db.test.count(['a'], 'fields', function (err, result) { | ||
db.test.count(db.fields(['a']), function (err, result) { | ||
@@ -564,3 +564,3 @@ expect(err).to.not.exist(); | ||
db.test.count({ a: 1 }, 'filter', function (err, count) { | ||
db.test.count({ a: 1 }, function (err, count) { | ||
@@ -590,3 +590,3 @@ expect(err).to.not.exist(); | ||
db.test.count({ a: 1 }, 'filter', function (err, count) { | ||
db.test.count({ a: 1 }, function (err, count) { | ||
@@ -593,0 +593,0 @@ expect(err).to.not.exist(); |
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
51905
1178