cmbf-hapi-restmodel
Advanced tools
Comparing version 0.4.5 to 0.4.6
@@ -77,6 +77,6 @@ var Joi = require('joi'), | ||
options = options || {}; | ||
var coll = this.constructor.db.collection(this.constructor.collection); | ||
var coll = this.db.collection(this.collection); | ||
return coll.find(options.filter).toArray().then((results) => { | ||
if(options.wrap) { | ||
return P.map(results, function(r){ return this.constructor.wrap(r)}); | ||
return P.map(results, function(r){ return this.wrap(r)}); | ||
} | ||
@@ -90,9 +90,9 @@ else { | ||
static show(id) { | ||
log.debug("show %s ", this.constructor.name, id); | ||
log.debug("show %s ", this.name, id); | ||
var _this = this; | ||
var coll = this.constructor.db.collection(this.constructor.collection); | ||
var coll = this.db.collection(this.collection); | ||
var q = {}; | ||
q[this.constructor.idField] = id; | ||
q[this.idField] = id; | ||
return coll.findOne(q).then(function(data) { | ||
return _this.constructor.wrap(data); | ||
return _this.wrap(data); | ||
}); | ||
@@ -102,3 +102,3 @@ } | ||
static wrap(data) { | ||
if(!(data instanceof this.constructor)) { | ||
if(!(data instanceof this)) { | ||
return new this(data); | ||
@@ -140,5 +140,5 @@ } | ||
log.debug("Remove", id); | ||
var coll = this.constructor.db.collection(this.constructor.collection); | ||
var coll = this.db.collection(this.collection); | ||
var q= {}; | ||
q[this.constructor.idField] = id; | ||
q[this.idField] = id; | ||
return coll.removeOne(q); | ||
@@ -145,0 +145,0 @@ } |
{ | ||
"name": "cmbf-hapi-restmodel", | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"author": "Joel Grenon <joelgrenon@covistra.com>", | ||
@@ -5,0 +5,0 @@ "description": "Hapi plugin building a REST Api from Joi schema, backed by covistra-mongo plugin", |
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
31197