Tiny package to add class functionality to Meteor in general and to collections.
We wrapped the by the Meteor recommended way of creating classes and adding it to the transform options of Mongo.Collection, so we have a cleaner syntax.
meteor add japetheape:class-helpers
In this example we make a simple class and attach it to a collection so every find returns an instance of this class.
Here we define a simple class.
var Game = ClassHelpers.createClass({
test: function() {
return 'test';
}
});
var gameInstance = new Game();
gameInstance.test();
Games = new Mongo.collection('game')
Games.attachClass(Game);
// fetch the first game
var game = Games.findOne();
game.test()
// -> 'test'
Written by: http://jaapvandermeer.com of http://ape55.com, contact us for Meteor projects!