ducky/web
2015-07-07
Parent:791aec3eb17b
ducky/web/src/models/profile.js
Implement subscriptions. Create a Subscription model and a Subscriptions collection, and attach them to the app context. Add a helper to our Profile model to retrieve the Subscription of that model. Still not sure this should be on the Profile--wouldn't it be better on the Me model? Isn't that generally where we would need it?
1.1 --- a/src/models/profile.js Tue Jul 07 21:25:49 2015 -0400 1.2 +++ b/src/models/profile.js Tue Jul 07 21:29:19 2015 -0400 1.3 @@ -23,4 +23,16 @@ 1.4 } 1.5 } 1.6 }, 1.7 + 1.8 + subscription() { 1.9 + return new Promise((resolve, reject) => { 1.10 + app.subscriptions.getOrFetch(this.id, (err, model) => { 1.11 + if (err) { 1.12 + reject(err) 1.13 + } else { 1.14 + resolve(model) 1.15 + } 1.16 + }) 1.17 + }) 1.18 + }, 1.19 })