ember-model icon indicating copy to clipboard operation
ember-model copied to clipboard

The hasMany example on README doesnt work and is misleading

Open ahacking opened this issue 11 years ago • 2 comments

// hasMany example
var comments = newUser.get('comments');
comments.create({text: "hello!"});
comments.save(); // POST to /comments.json

There is no create method defined for a non embedded hasMany relationships so this example is actually impossible as the hasMany relationship in the example is NOT embedded which is the only case where create is defined on the RecordArray.

The example is also misleading as it suggests that Ember.Model would setup the foreign key on the newly created model but it currently doesn't have support for that, or the ability to express either inverse relationships or foreign keys on relationship definitions which would be required for it to work properly.

ahacking avatar Apr 24 '14 04:04 ahacking

d'oh... sorry about that, we need to update the docs to reflect the new store API as well... PRs welcome as well if you have the time :)

ebryn avatar Apr 24 '14 04:04 ebryn

There is a bunch of stuff I need in Ember-Model so I am willing to contribute functionality as required.

What are your plans for relationships? There are a number of things I would like to solve with relationships:

  • relationship creation with foreign key set (using inverse relationship or explicit foreign key option in relationship definition)
  • fetching strategies (ie use parent key to find children rather than explicit child id's)
  • control on how deep fetching or saving of related models goes

ahacking avatar Apr 24 '14 05:04 ahacking