Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 30, 2016
Merged

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

merged 1 commit into from
Aug 30, 2016

Conversation

pangratz
Copy link
Member

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
Member

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

@pangratz
Copy link
Member Author

pangratz commented Aug 23, 2016

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
Copy link
Member

bmac commented Aug 25, 2016

👍

@pangratz pangratz merged commit f5161b0 into emberjs: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