dimanche 22 mars 2015

EmberJS and REST

community!


I have an ember-data model post.



`import DS from "ember-data";`

attr = DS.attr
belongsTo = DS.belongsTo
hasMany = DS.hasMany

Post = DS.Model.extend({
title: attr('string')
url: attr('string')
text: attr('string')
userId: attr('number')
createdAt: attr('date')
updatedAt: attr('date')
user: belongsTo('user', async: true)
comments: hasMany('comment', async: true)
comments_length: attr('number')
});

`export default Post;`


It gets data from /api/posts.

Also, I have comments and when comment is added, post is updated.

I can get last updated posts at /api/posts/last_updated.

How to do this properly at EmberJS?





Aucun commentaire:

Enregistrer un commentaire