meteor/meteor — pull request #267 by tmeasday (2012-08-10 04:08:01+00:00)
Title: Model support

I've created a new PR as the old one was against the wrong branch and it was frustrating. Sorry!.

Here's the previous discussion: #129

To summarize: This is a working system to attach a `ctor` to be applied to each document coming out of mongo. It allows you to use a model system, for example this package works with it: https://github.com/tmeasday/meteor-models

Also, [League](http://beta.getleague.com) ([source](https://github.com/tmeasday/league)) currently uses it without problems (so far!).

Once again, here at the most basic level is what it does:

```js
Team = function(doc) {
this.value = doc.value;
};
Team.prototype.printValue = function() {
console.log(this.value);
}

Teams = new Meteor.Collection('teams', null, null, Team)

Teams.findOne().printName()
```

There are still some questions outstanding and things that will need to be resolved before it can be merged, but this is as far as I can take it without feedback.