Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

made static methods work on models in a more sane way

  • Loading branch information...
commit 7cf93ae04dd443c5c6751ac2ecab5b631ebe2f66 1 parent 146c9ce
@Techwraith Techwraith authored
Showing with 14 additions and 0 deletions.
  1. +2 −0  lib/index.js
  2. +8 −0 test/adapters/shared.js
  3. +4 −0 test/fixtures/user.js
View
2  lib/index.js
@@ -534,6 +534,8 @@ utils.mixin(model, new (function () {
// Mix in the static methods like .create and .load
utils.mixin(ModelCtor, _createStaticMethodsMixin(name));
+ // Mix on the statics
+ utils.mixin(defined, ModelDefinition);
// Same with statics
utils.mixin(ModelCtor, defined);
// Same with EventEmitter methods
View
8 test/adapters/shared.js
@@ -386,6 +386,14 @@ tests = {
});
}
+, 'test Static methods on model': function (next) {
+ User.findByLogin('asdf', function (err, data) {
+ assert.equal(data.length, 3);
+ if (err) {
+ throw err;
+ }
+ });
+ }
};
module.exports = tests;
View
4 test/fixtures/user.js
@@ -22,6 +22,10 @@ User.prototype.someMethod = function () {
// Do some stuff on a User instance
};
+User.findByLogin = function (login, callback) {
+ User.all({login: login}, callback);
+}
+
User = model.register('User', User);
module.exports.User = User;
Please sign in to comment.
Something went wrong with that request. Please try again.