Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tmeasday/meteor-models
https://github.com/tmeasday/meteor-models
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tmeasday/meteor-models
- Owner: tmeasday
- Created: 2012-06-25T04:57:01.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-14T00:54:16.000Z (almost 11 years ago)
- Last Synced: 2024-10-04T12:58:36.439Z (3 months ago)
- Language: JavaScript
- Size: 156 KB
- Stars: 25
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
Meteor Models
=============This is a basic proof of concept of the way meteor models *could* work. It builds on the code in this [pull request](https://github.com/meteor/meteor/pull/129).
To use, do something like
```js
var Post = function(attrs) {
Model.call(this, attrs);
}
Post.prototype = new Model({});
Post.prototype.constructor = Post;var Posts = Post._collection = new Meteor.Collection('posts', null, null, Post);
```Then 2 things happen, firstly you can use the Model class to save and update posts:
```js
var post = new Post({title: 'A great post'});
post.save();
```And when you query the collection, you will get posts out:
```js
var post = Posts.findOne(); // a Post object
post.update_attribute('title', 'a new title');
```For some ideas on how this could be expanded in the future, see the [model class](https://github.com/percolatestudio/league/blob/master/models/_model.coffee) from the League project.