I have a ember-data model which has a belongsTo
relationship and I'd like test whether there is any value (aka, foreign key reference) in this relationship. I initially thought I could just state:
if(myModel.rel !== null) {
// do something now that belongsTo relationship has a value
}
But of course this doesn't work because myModel.rel
would never be null and instead is some sort of Ember Data object. Ok fine. I adjusted this to:
if(myModel.rel.content !== null) {
// do something now that belongsTo relationship has a value
}
This does work but I feel like maybe this is a bit too "hacky" ... is there a cleaner, more API driven way of stating this conditional in Ember Data?
Aucun commentaire:
Enregistrer un commentaire