dimanche 11 janvier 2015

Find by related objects

I've got two Models (Posts and Categories):



var Post = DS.Model.extend({
title: DS.attr('string'),
permalink: DS.attr('string'),
body: DS.attr('string'),
category: DS.belongsTo('category')
});

var Category = DS.Model.extend({
name: DS.attr('string'),
permalink: DS.attr('string'),
posts: DS.hasMany('post',{async:true})
});


The relationship is working fine. Now I'd like to request all posts belonging to a certain category (identified by its permalink). What would be the best way to accomplish this?


Aucun commentaire:

Enregistrer un commentaire