Created
July 2, 2014 17:10
-
-
Save rcy/57518aebdf6d920316c0 to your computer and use it in GitHub Desktop.
simple model wrapper for Meteor collections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Model = { | |
create: function (collection, methods) { | |
var model = function (doc) { | |
_.extend(this, doc); | |
}; | |
_.extend(model.prototype, methods); | |
collection._transform = function (doc) { | |
return new model(doc); | |
}; | |
return model; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment