mercredi 26 août 2015

How do I pluck user ids from all comments of an article?

I have an article that hasMany comments. A comment belongsTo a user and an article. So basically a comment has an article and user foreign key id.

I am trying to "pluck" / place all of the comment user ids, of the article, into an array.

I have a computed property that does:

userIds: Ember.computed('article.comments.length', {
  get() {
    return this.get(‘article.comments’).mapBy(‘user.id’);
  }
})

Returns: [undefined].

Expected result: [1,2,3,4]. Assuming 1,2,3,4 are user ids.




Aucun commentaire:

Enregistrer un commentaire