One to none or one way relationships


#1

I am not sure I have the exact terminology here, but does ember data support something like a one way relationship between models. I would describe it as either:

one to none or one to many

But only bound in one direction, so trying to understand the implications for the identity map.

Imagine the following models

App.Thing = DS.Model.extend({
  name: DS.attr(),
  other: DS.belongsTo('other')
});

App.Other = DS.Model.extend({
  foo: DS.attr(),
  bar: DS.attr(),
  baz: DS.attr(),
});

Note how Other doesn’t has any explicit link back to Thing

Is this legal and can you do stuff like this?

{{ thing.other.foo }}
{{ thing.other.bar }}
{{ thing.other.baz }}

In my design the inverse doesn’t make sense

{{ other.thing }}

If this possible in ember-data without causing serious problems?


#2

Hello, please have you found solution to this? I am new to ember and I am trying to create app where I have notes. Every note has many tags. But tags does need to know about notes.


#3

Interesting question. I also have small experience with ember data, In last project I have same issue, but I use “one to none” link between models and have not any problems. All things works as they should.