Best practice, many-to-many

Hi,

I’m a backend-guy, trying to to set up an API to be as comfortable as possible for our front-end guy, using ember.

We’re currently using the ActiveModel-adapter towards a custom server, but we’re obviously open to switching if there’s a sufficiently good reason for it.

We’ve run into an issue with many-to-many-relations, and I can’t quite sort where ember data is currently at with regards to that.

Searching turns up a lot of information, some of it outdated, and a lot of the discussions trail over to polymorphic relations more than many-to-many.

The official documentation clearly states that many-to-many are supported:

http : / / Defining Models - Ember Data - Ember Guides

But it offers little guidance on how to set this up for persisting those objects on the server-side.

What we’d like to do, is set up a relationship using a concept similar to Rubys “has_many through”-concept.

The seemingly most linked post on this:

https : / / github.com/emberjs/data/issues/120

Does mention that it’s desirable to support something like that, but as of a year ago, it was not:

http : / / Ember.js "hasMany through" - Stack Overflow

The issue (120) has been closed though, and yet the documentation doesn’t seem to offer any advice on how this can be set up.

That leaves everything a bit unclear. Apparently it’s desirable to support it, and the linked issue is closed, yet the documentation offers nothing, and most posts on setting up many-to-many-relationships mostly offer advice on setting up polymorphic relationships, which doesn’t quite help.

It’s not a huge crisis for us, we could always use a third object with hasMany towards the two models we’re trying to bind, it would just be more comfortable with a “native” binding between the two.

Anyone know what’s up?

(other than taxes and prices I mean… )

tld

I tried for a while the classic approach without the third object and it was becoming painful at some point, I resolved for using a third model and it really helped a lot, creating,deleting or updating a relationship became easier to manage, it also makes faster my api, since I would n’t need to have the join that rails does to determinate which are the ids for a relationship, I just pass a link.