Skip to content

[BUGFIX beta] add assertions for reference methods on DS.Model - #4499

Merged
pangratz merged 1 commit into
warp-drive-data:masterfrom
pangratz:add-reference-assertions
Aug 30, 2016
Merged

[BUGFIX beta] add assertions for reference methods on DS.Model#4499
pangratz merged 1 commit into
warp-drive-data:masterfrom
pangratz:add-reference-assertions

Conversation

@pangratz

Copy link
Copy Markdown
Contributor

Assertions are thrown when the specified relationship doesn't exist or
the passed type mismatches the one of the actual relationship.


This issue has been raised in the slack channel so adding assertions should help preventing this in the future.

Assertions are thrown when the specified relationship doesn't exist or
the passed type mismatches the one of the actual relationship.
@fivetanley

Copy link
Copy Markdown
Contributor

is there a way to check for existence of a relationship without getting an exception?

@pangratz

pangratz commented Aug 23, 2016

Copy link
Copy Markdown
Contributor Author

Yep:

let Person = this.store.modelFor("person");
let rels = Ember.get(Person, "relationshipsByName"); 
let personRel = rels.get("father");
if (personRel) {
  let { kind } = personRel;
  assert.ok(kind, "belongsTo");
}

@bmac

bmac commented Aug 25, 2016

Copy link
Copy Markdown
Contributor

👍

@pangratz
pangratz merged commit f5161b0 into warp-drive-data:master Aug 30, 2016
@pangratz
pangratz deleted the add-reference-assertions branch August 30, 2016 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants