You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My question is: is it expected behaviour that an issue is always stored in the database with features as an empty array? When you visit the example application, you can see that it thinks, upon load, that the lone issue has 0 features. When you click the Load features button, it runs store.find('feature'), and suddenly the feature is connected to its parent issue.
There’s a button to print the contents of the PouchDB, here’s example output:
Maybe I am constructing the models in the wrong way? In my real application, I’m constructing test models in acceptance tests. For the example application, I made an initialiser to do the same:
{name: 'data-populator',after: 'store',initialize: function(container,application){application.deferReadiness();varstore=container.lookup('store:main');varissues=store.find('issue');issues.then(function(){if(issues.get('length')==0){varissue=store.createRecord('issue',{title: 'An issue'});issue.save().then(function(){varfeature=store.createRecord('feature',{title: 'A feature'});issue.get('features').pushObject(feature);feature.save();issue.save().then(function(){application.advanceReadiness();});});}else{application.advanceReadiness();}});}}
I’ve tried a variety of ways of constructing the models, like passing in the issue when creating a feature:
var feature = store.createRecord('feature', {issue: issue, title: 'A feature'});
and many other variations, but never have I seen the features array be anything but empty in the database.
I’ve been using weird workarounds like pre-loading all features in the issues route, and similarly for other related models, but I suspect I’m just missing something.
The text was updated successfully, but these errors were encountered:
Hello! Thanks for your work on this, I’m happy that Ember Data and PouchDB are closer to working smoothly together.
I’m having trouble understanding how to create related models, which is maybe what #8 was about, but that person’s resolution was unclear to me.
I created a simple example application, which is running here.
Here are the models, representing issues of a magazine and the features within them:
app/models/issue.js
:app/models/feature.js
:Nothing special.
My question is: is it expected behaviour that an
issue
is always stored in the database withfeatures
as an empty array? When you visit the example application, you can see that it thinks, upon load, that the lone issue has 0 features. When you click theLoad features
button, it runsstore.find('feature')
, and suddenly the feature is connected to its parent issue.There’s a button to print the contents of the PouchDB, here’s example output:
Maybe I am constructing the models in the wrong way? In my real application, I’m constructing test models in acceptance tests. For the example application, I made an initialiser to do the same:
I’ve tried a variety of ways of constructing the models, like passing in the issue when creating a feature:
and many other variations, but never have I seen the
features
array be anything but empty in the database.I’ve been using weird workarounds like pre-loading all features in the issues route, and similarly for other related models, but I suspect I’m just missing something.
The text was updated successfully, but these errors were encountered: