Merge pull request #201 from anatoliychakkaev/master

Some tweaks
This commit is contained in:
Anatoliy Chakkaev 2013-01-30 07:33:48 -08:00
commit 03215fbf52
4 changed files with 7 additions and 9 deletions

View File

@ -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];

View File

@ -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);
});
};

View File

@ -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);
}
/**

View File

@ -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": [
{