{"action":"created","issue":{"url":"https://api.github.com/repos/modella/modella/issues/44","labels_url":"https://api.github.com/repos/modella/modella/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/modella/modella/issues/44/comments","events_url":"https://api.github.com/repos/modella/modella/issues/44/events","html_url":"https://github.com/modella/modella/pull/44","id":48310962,"number":44,"title":"Modella 1.0.0","user":{"login":"MatthewMueller","id":170299,"avatar_url":"https://avatars.githubusercontent.com/u/170299?v=3","gravatar_id":"","url":"https://api.github.com/users/MatthewMueller","html_url":"https://github.com/MatthewMueller","followers_url":"https://api.github.com/users/MatthewMueller/followers","following_url":"https://api.github.com/users/MatthewMueller/following{/other_user}","gists_url":"https://api.github.com/users/MatthewMueller/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthewMueller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthewMueller/subscriptions","organizations_url":"https://api.github.com/users/MatthewMueller/orgs","repos_url":"https://api.github.com/users/MatthewMueller/repos","events_url":"https://api.github.com/users/MatthewMueller/events{/privacy}","received_events_url":"https://api.github.com/users/MatthewMueller/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-11-10T20:38:21Z","updated_at":"2015-01-05T22:03:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/modella/modella/pulls/44","html_url":"https://github.com/modella/modella/pull/44","diff_url":"https://github.com/modella/modella/pull/44.diff","patch_url":"https://github.com/modella/modella/pull/44.patch"},"body":"# Modella 1.0.0\r\n\r\nModella 1.0.0 is on the horizon. It's not working yet, but it's getting really close. 1.0.0 was rewritten from the ground up to offer support for some of the latest browser and server-side features. As a result, Modella 1.0.0 will be a **breaking change**. Modella has a more refined API. Most plugins will need to be updated (or pinned).\r\n\r\nSome of the features coming:\r\n\r\n## getter/setter support\r\n\r\nOld:\r\n\r\n```js\r\nUser.attr('name').attr('age')\r\n\r\nuser.name('matt')\r\nuser.age(25)\r\n```\r\n\r\nNew:\r\n\r\n```js\r\nUser.attr('name').attr('age')\r\n\r\nuser.name = 'matt';\r\nuser.age = 25;\r\n```\r\n\r\nThis applies to some other operations as well:\r\n\r\nOld:\r\n\r\n```js\r\nuser.toJSON()\r\nuser.primary(2)\r\n```\r\n\r\nNew:\r\n\r\n```js\r\nuser.json\r\nuser.primary = 2;\r\n```\r\n\r\n## Optional generator support in environments that support it\r\n\r\nOld:\r\n\r\n```js\r\nuser.save(function () { ... });\r\n```\r\n\r\nNew:\r\n\r\n```js\r\nyield user.save();\r\n// or...\r\nuser.save(function () { ... });\r\n```\r\n\r\n## Multiple syncs\r\n\r\nBefore modella 1.0.0, you couldn't have multiple sync layers on the same model. Now it's easier than ever to add multiple sync layers\r\n\r\nOld:\r\n\r\n```js\r\nmodel.create = fn;\r\n```\r\n\r\nNew:\r\n\r\n```js\r\nmodel.sync.create = function a() {};\r\nmodel.sync.create = function b() {};\r\n```\r\n\r\n## Remove .save()\r\n\r\n**Under consideration:** We all love `.save()`, but it makes way too many assumptions about how you're going to save and which events it should fire. Replace with `.create()` and `.update()`\r\n\r\n## Hooks\r\n \r\nIn addition to events, you will now be able to hook into, `before` and `after` events on all CRUD operations. These hooks can be synchronous, asynchronous or generator functions.You can also define your own hooks using `Model.hook(...)` & `Model.trigger(...)`.\r\n\r\n## More\r\n\r\nHere's a stream of consciousness on how the API looks:\r\n\r\n```js\r\n// server & browser\r\nvar user = User(attrs)\r\n\r\n// STATIC:\r\n\r\n// setting attributes\r\nUser.attr(name, opts)\r\n\r\n// computing attributes\r\nUser.computed(name, str|fn)\r\n\r\n// PROTOTYPE:\r\n\r\nuser.changed()\r\n\r\n// set an object\r\nuser.attr[name] = value\r\n\r\n// get or set the primary\r\nuser.primary\r\n\r\n// return json\r\nuser.json\r\n\r\n// has the model been\r\n// synced from a remote\r\nuser.synced\r\n\r\n// COMMON:\r\n\r\n// use a plugin\r\n// used to set up events, hooks and syncs\r\n// optionally pass an environment variable\r\nUser.use([env], fn);\r\n\r\n// events\r\n// don't modify or halt execution flow\r\n// may or may not modify state\r\n// unordered, run asynchronously\r\nUser.on(event, fn);\r\nUser.emit(event, [args, ...])\r\n\r\n// hooks\r\n// may halt execution flow\r\n// will probably modify state\r\n// ordered, run sequentially\r\nUser.hook(event, fn|gen);\r\nUser.trigger(event, [args, ...], [done])\r\n\r\n// SYNC:\r\n\r\n// predefined events\r\ncreating\r\ncreated\r\nupdating\r\nupdated\r\nremoving\r\nremoved\r\nfinding\r\nfound\r\nsaving\r\nsaved\r\n\r\n// setters & getters\r\nUser.create // batch\r\nuser.create // single\r\nUser.update // batch\r\nuser.update // single\r\nUser.remove // batch\r\nuser.remove // single\r\nUser.all    // find many\r\nUser.find   // find one\r\n\r\n// signatures\r\n\r\n  // static:\r\n  User.find(query, [opts], [fn])\r\n  User.sync.find = function(query, opts, fn) {}\r\n\r\n  User.all(query, [opts], [fn])\r\n  User.sync.all = function(query, opts, fn) {}\r\n\r\n  User.create(users, [opts], [fn])\r\n  User.update(users, [opts], [fn])\r\n  User.remove(users, [opts], [fn])\r\n\r\n  // proto:\r\n  user.create([opts], [fn])\r\n  User.sync.create = function(opts, fn) {}\r\n  user.update([opts], [fn])\r\n  User.sync.update = function(opts, fn) {}\r\n  user.remove([opts], [fn])\r\n  User.sync.remove = function(opts, fn) {}\r\n```\r\n\r\n---\r\n\r\nLet me know if you have any questions or thoughts!\r\n"},"comment":{"url":"https://api.github.com/repos/modella/modella/issues/comments/68790121","html_url":"https://github.com/modella/modella/pull/44#issuecomment-68790121","issue_url":"https://api.github.com/repos/modella/modella/issues/44","id":68790121,"user":{"login":"dweinstein","id":794478,"avatar_url":"https://avatars.githubusercontent.com/u/794478?v=3","gravatar_id":"","url":"https://api.github.com/users/dweinstein","html_url":"https://github.com/dweinstein","followers_url":"https://api.github.com/users/dweinstein/followers","following_url":"https://api.github.com/users/dweinstein/following{/other_user}","gists_url":"https://api.github.com/users/dweinstein/gists{/gist_id}","starred_url":"https://api.github.com/users/dweinstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dweinstein/subscriptions","organizations_url":"https://api.github.com/users/dweinstein/orgs","repos_url":"https://api.github.com/users/dweinstein/repos","events_url":"https://api.github.com/users/dweinstein/events{/privacy}","received_events_url":"https://api.github.com/users/dweinstein/received_events","type":"User","site_admin":false},"created_at":"2015-01-05T22:03:01Z","updated_at":"2015-01-05T22:03:01Z","body":"- :-1: on getters/setters\r\n- :+1: keeping toJSON()"}}