proton-model
Advanced tools
Comparing version 1.1.9 to 1.2.0
25
index.js
@@ -47,3 +47,2 @@ 'use strict' | ||
this._schema = this.mongoose.Schema(this.schema()) | ||
console.log('Schema', this.mongoose.Schema, this._schema) | ||
this._createStaticMethods(constructor) | ||
@@ -60,2 +59,3 @@ // this._createInstanceMethods(prototype) | ||
if (this._isInstanceMethod(name, method)) { | ||
this.proton.log.silly('Instance method', name, method.value) | ||
this._schema.method(name, method.value) | ||
@@ -71,2 +71,3 @@ } | ||
if (this._isStaticMethod(name, method)) { | ||
this.proton.log.silly('Static method', name, method.value) | ||
this._schema.statics[name] = method.value | ||
@@ -82,2 +83,3 @@ } | ||
if (this._isVirtualMethod(name, method)) { | ||
this.proton.log.silly('Virtual method', name, method.value) | ||
this._setVirtualMethod(name, method) | ||
@@ -89,15 +91,26 @@ } | ||
_isStaticMethod(name, method) { | ||
return (name !== 'prototype' && name != 'schema' && name !== 'length') | ||
return ( | ||
name && | ||
name !== 'prototype' && | ||
name != 'schema' && | ||
name !== 'length' | ||
) | ||
} | ||
_isInstanceMethod(name, method) { | ||
return (name !== 'constructor' && | ||
return ( | ||
name && | ||
name !== 'constructor' && | ||
name != 'schema' && | ||
!(method.set || method.get)) | ||
!(method.set || method.get) | ||
) | ||
} | ||
_isVirtualMethod(name, method) { | ||
return (name !== 'constructor' && | ||
return ( | ||
name && | ||
name !== 'constructor' && | ||
name != 'schema' && | ||
(_.has(method, 'set') || _.has(method, 'get'))) | ||
(_.has(method, 'set') || _.has(method, 'get')) | ||
) | ||
} | ||
@@ -104,0 +117,0 @@ |
{ | ||
"name": "proton-model", | ||
"version": "1.1.9", | ||
"version": "1.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
3759
102