Skip to content

Commit

Permalink
Merge branch 'release/0.1.13'
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrockwell committed Sep 20, 2015
2 parents a0e8551 + ad897c4 commit 8bef077
Show file tree
Hide file tree
Showing 13 changed files with 1,132 additions and 230 deletions.
60 changes: 36 additions & 24 deletions es5/lib/model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,17 @@ var Model = (function () {
this.initialize();
}

/**
* STATIC INTERFACE
*/

_createClass(Model, [{
key: "hasOne",

/**
* INSTANCE INTERFACE
*/

value: function hasOne(associationName, associationConstructor) {
return this[_symbols2["default"].addAssociation]({
name: associationName,
Expand Down Expand Up @@ -176,7 +185,7 @@ var Model = (function () {
* Return a boolean indicating whether the model is valid or not.
*
* @method isValid
* @param {Function(boolean)} callback Callback returning the boolean.
* @param {Function(boolean)} callback Callback returning the boolean.
*/
}, {
key: "isValid",
Expand All @@ -192,12 +201,12 @@ var Model = (function () {
* @example
* ```
* model.invalidAttributes((invalidAttributeList) => {
* console.log(invalidAttributeList); // {"name":["Cannot contain special characters", "Cannot contain numbers"], "age":["Cannot be under 18"]}
* console.log(invalidAttributeList); // {"name":["Cannot contain special characters", "Cannot contain numbers"], "age":["Cannot be under 18"]}
* });
* ```
*
* @method invalidAttributes
* @param {Function(invalidAttributeList)} callback Callback returning the invalid attribute list.
* @param {Function(invalidAttributeList)} callback Callback returning the invalid attribute list.
*/
}, {
key: "invalidAttributes",
Expand Down Expand Up @@ -485,6 +494,30 @@ var Model = (function () {

return fieldAttributes;
}
}], [{
key: "database",
get: function get() {
var database = this._database;
if (!database) {
database = Model._database;
}
return database;
},
set: function set(newDatabase) {
this._database = newDatabase;
}
}, {
key: "find",
get: function get() {
var modelQuery = new _modelFinderJs2["default"](this.database);
return modelQuery.find(this);
}
}, {
key: "count",
get: function get() {
var modelQuery = new _modelFinderJs2["default"](this.database);
return modelQuery.count(this);
}
}]);

return Model;
Expand All @@ -498,25 +531,4 @@ Object.assign(Model.prototype, _defineProperty({
"delete": require("./delete.js")
}, _symbols2["default"].addAssociation, require("./addAssociation.js")));

Object.defineProperties(Model, {
"database": {
get: function getDatabase() {
var database = this._database;
if (!database) {
database = Model._database;
}
return database;
},
set: function setDatabase(value) {
this._database = value;
}
},
"find": {
get: function modelFind() {
var modelQuery = new _modelFinderJs2["default"](this.database);
return modelQuery.find(this);
}
}
});

module.exports = exports["default"];
Loading

0 comments on commit 8bef077

Please sign in to comment.