commit
03215fbf52
|
@ -133,7 +133,7 @@ AbstractClass.whatTypeName = function (propName) {
|
|||
AbstractClass._forDB = function (data) {
|
||||
var res = {};
|
||||
Object.keys(data).forEach(function (propName) {
|
||||
if (this.whatTypeName(propName) === 'JSON' || data[propName] instanceof Array) {
|
||||
if (this.whatTypeName(propName) === 'JSON') {
|
||||
res[propName] = JSON.stringify(data[propName]);
|
||||
} else {
|
||||
res[propName] = data[propName];
|
||||
|
|
|
@ -242,6 +242,9 @@ Schema.prototype.define = function defineClass(className, properties, settings)
|
|||
|
||||
return NewClass;
|
||||
|
||||
|
||||
};
|
||||
|
||||
function standartize(properties, settings) {
|
||||
Object.keys(properties).forEach(function (key) {
|
||||
var v = properties[key];
|
||||
|
@ -257,9 +260,6 @@ Schema.prototype.define = function defineClass(className, properties, settings)
|
|||
// or {timestamps: {created: 'created_at', updated: false}}
|
||||
// by default property names: createdAt, updatedAt
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Define single property named `prop` on `model`
|
||||
*
|
||||
|
@ -300,11 +300,9 @@ Schema.prototype.defineProperty = function (model, prop, params) {
|
|||
*/
|
||||
Schema.prototype.extendModel = function (model, props) {
|
||||
var t = this;
|
||||
standartize(props, {});
|
||||
Object.keys(props).forEach(function (propName) {
|
||||
var definition = props[propName];
|
||||
if (typeof definition === 'function' || typeof definition !== 'object') {
|
||||
definition = {type: definition};
|
||||
}
|
||||
t.defineProperty(model, propName, definition);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -245,7 +245,7 @@ function validateFormat(attr, conf, err) {
|
|||
* Custom validator
|
||||
*/
|
||||
function validateCustom(attr, conf, err, done) {
|
||||
conf.customValidator.call(this, err, done);
|
||||
conf.customValidator.call(this, err, attr, done);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "jugglingdb",
|
||||
"description": "ORM for every database: redis, mysql, neo4j, mongodb, couchdb, postgres, sqlite",
|
||||
"version": "0.2.0-15",
|
||||
"version": "0.2.0-17",
|
||||
"author": "Anatoliy Chakkaev <rpm1602@gmail.com>",
|
||||
"contributors": [
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue