mardi 25 octobre 2016

Hasmany relationship in ember with array id

I have some trouble with has_many relationship in ember, let's say I want to retrieve the comments attached to a post, I can easily do it if my Postgres schema looks like this:

posts:

{
  id: 1,
  comments: [1, 2, 3]
}

comments:

{
  id: 3,
  post_id: 1
}

But what I want is to get rid of the "comments" in posts table, like:

posts:

{
  id: 1
}

comments

{
  id: 3,
  post_id: 1
}

So far I haven't found anything that can help me even if it doesn't seem hard :(

I would be glad if someone can help me do that :)




Aucun commentaire:

Enregistrer un commentaire