javascript - Ember find existing hasMany models -
how can (or rather check existence of) sub-model objects belong parent model in ember-data (v1.13.15) without throwing errors?
i have associated models looking this:
// models/parent.js ... export default ds.model.extend({ children: ds.hasmany('child', {async:true, inverse:'parent'}), ... }); // models/child.js ... export default ds.model.extend({ parent: ds.belongsto('parent', {async:true, inverse:'children'}), .... });
in route's model hook i'm trying check if have children associated parent (parent btw submodel of hasmany/belongsto of 'family' model...). if haven't added children yet, need create , associate them parent object, when like:
parent.get('children').then(function(children){ // nice in here , maybe have children.length == 0 });
i uncaught (in promise) typeerror: cannot read property 'then' of undefined
. can't call parent.get('children').get('length')
. this.store.findall('child').then...
seems error out.
is not possible empty array or have use dirty catch figure out if have submodels? i'm pretty inexperienced ember pointers or appreciated. thanks!
Comments
Post a Comment