Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4836

Map JSON array of object ids to model?

$
0
0

@JMendoza wrote:

Hey! I am doing a simple search of posts, and I am having trouble rendering model, I am receiving this from server side (array of post ids, and the post models

 posts: [{ id:1,...}, {id:2,...}]                   
            
 searches:[ {
              posts:[1,2,3,...]
                  } ]

I have a model search, that i use to send the input search text and retrieve the post ids:

 import DS from 'ember-data';

 var attr= DS.attr;

export default DS.Model.extend({
 word: attr('string'),
 category: attr('string'),
 posts: attr()
});

I know it has something to do with overriding the serializer, but I am not sure, I don't use relationships either, so is there some way I can map the array of ids to the post model and render the data in template?? Thanks!

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4836

Trending Articles