diamond.js
Advanced tools
Comparing version 0.2.17 to 0.2.18
@@ -49,3 +49,8 @@ // Generated by CoffeeScript 1.8.0 | ||
Model.prototype.get = function(name) { | ||
return this.properties[name]; | ||
var m; | ||
m = this; | ||
name.split('.').forEach(function(p) { | ||
return m = m.properties[p]; | ||
}); | ||
return m; | ||
}; | ||
@@ -52,0 +57,0 @@ |
@@ -29,9 +29,11 @@ // Generated by CoffeeScript 1.8.0 | ||
} | ||
if (!value) { | ||
if (value == null) { | ||
if (this["default"] != null) { | ||
value = typeof this["default"] === "function" ? this["default"].call(this.model) : this["default"]; | ||
value = typeof this["default"] === "function" ? this["default"].call(model) : this["default"]; | ||
} else { | ||
value = this.type(); | ||
value = this.type.prototype ? new this.type : this.type(); | ||
} | ||
} else { | ||
} else if (value.properties != null) { | ||
return value; | ||
} else if (value.constructor !== this.type) { | ||
value = this.type(value); | ||
@@ -38,0 +40,0 @@ } |
@@ -26,4 +26,32 @@ // Generated by CoffeeScript 1.8.0 | ||
Storage.prototype.find = function(callback) { | ||
return this.constructor.find(this.constructor, this.properties, callback); | ||
}; | ||
Storage.prototype.findById = function(callback) { | ||
return this.constructor.findById(this.constructor, this.id, callback); | ||
}; | ||
Storage.save = function(model, callback) { | ||
var k, properties, v, _ref; | ||
properties = model.properties; | ||
if (!model.hasError) { | ||
_ref = model.properties; | ||
for (k in _ref) { | ||
v = _ref[k]; | ||
if (this.properties[k]) { | ||
if (this.properties[k].save) { | ||
properties[k] = this.properties[k].save.call(this, v); | ||
} | ||
} | ||
} | ||
return Diamond.getInstance().db.save(this.collection, properties, callback); | ||
} else { | ||
return callback(model.errors); | ||
} | ||
}; | ||
Storage.prototype.save = function(callback) { | ||
var k, v, _ref; | ||
var k, properties, v, _ref; | ||
properties = this.properties; | ||
if (!this.hasError) { | ||
@@ -35,7 +63,7 @@ _ref = this.properties; | ||
if (this.constructor.properties[k].save) { | ||
this.properties[k] = this.constructor.properties[k].save.call(this, v); | ||
properties[k] = this.constructor.properties[k].save.call(this, v); | ||
} | ||
} | ||
} | ||
return Diamond.getInstance().db.save(this, callback); | ||
return Diamond.getInstance().db.save(this.collection, properties, callback); | ||
} else { | ||
@@ -47,3 +75,4 @@ return callback(this.errors); | ||
Storage.prototype.update = function(options, callback) { | ||
var k, v, _ref; | ||
var k, properties, v, _ref; | ||
properties = this.properties; | ||
if (!this.hasError) { | ||
@@ -55,7 +84,7 @@ _ref = this.properties; | ||
if (this.constructor.properties[k].save) { | ||
this.properties[k] = this.constructor.properties[k].save.call(this, v); | ||
properties[k] = this.constructor.properties[k].save.call(this, v); | ||
} | ||
} | ||
} | ||
return Diamond.getInstance().db.update(this, options, this.properties, callback); | ||
return Diamond.getInstance().db.update(this.collection, options, properties, callback); | ||
} else { | ||
@@ -67,3 +96,3 @@ return callback(this.errors); | ||
Storage.update = function(options, set, callback) { | ||
return Diamond.getInstance().db.update(this, options, set, callback); | ||
return Diamond.getInstance().db.update(this.collection, options, set, callback); | ||
}; | ||
@@ -70,0 +99,0 @@ |
{ | ||
"name": "diamond.js", | ||
"description": "MVC web framework", | ||
"version": "0.2.17", | ||
"version": "0.2.18", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Arthur Xavier", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
28405
26
476