Comments (9)
@yial2 without async: true
the comments will not be fetched when store.find('post', 'post_id')
is called
from emberfire.
@aputinski , thanks for the quick reply.
You are right, It works as you described for one-to-many relationship, but it does seem to load one-to-one relationship differently depending on
{async: true}
10 App.Comment = DS.Model.extend({¬
9 body: DS.attr('string'),¬
8 published: DS.attr('number'),¬
7 publishedDate: function() {¬
6 var m = moment(this.get('published'));¬
5 return '%@ at %@'.fmt(m.format('MMMM Do, YYYY'), m.format('h:mm:ss a'));¬
4 }.property('published'),¬
3 user: DS.belongsTo('user')¬
2 });¬
taking from the blog example, please note
user: DS.belongsTo('user') //without the async: true
Another observation:
0 App.PostRoute = Ember.Route.extend({¬
1 model: function(params) {¬
2 return this.store.find('post', params.post_id).then(function(post){¬
3 //return post;¬
4 ¬
5 return Promise.cast(post.get('comments')).then(function(items) {¬
6 items.forEach(function(i){¬
7 //print undefined when async: true, print actual value without async: true¬
8 console.log(i.get('user').get('id'));¬
9 });¬
10 return post;¬
11 });¬
12 });¬
13 }¬
14 });¬
from emberfire.
@yial2 that's strange, I'll take a look and see what's going on.
from emberfire.
I have a related question. Is there a way to force all asyncs to load automatically? I have a few nested relationships and it only seems to load the first level. I have to make a call to a nested property for it to load the next async.
Also, there hasn't been much development on this in a while (a month or so) - can we expect anything soon?
Thx!
from emberfire.
I'm not sure if Ember Data supports loading all async relationships.
If this is something you have time to look into, it would be great to see a pull request.
EmberFire is officially supported by Firebase, unfortunately I just don't have the bandwidth to work on it right now.
from emberfire.
@aputinski actually, I didn't have my data syncd in both directions. Once I did that, it solved my issue. So I made a PR to update the docs to show the data syncing in both directions. :)
from emberfire.
regarding this and #108
am i correct to say that a async: false does not mean the data is eager loaded automatically?
from emberfire.
according to this http://discuss.emberjs.com/t/what-is-an-async-relationship-async-true-vs-async-false/4107/6
async: false CAN load stuff in eagerly if and only if the server (firebase) can return something like
stuff: DS.hasMany('stuff', {async: false})
{
stuff: [ { id: 1, user_id: 1 }, { id: 2, user_id: 1 }, { id: 3, user_id: 1 } ],
user: { id: 1, stuff_id: [1, 2, 3] }
}
where as
stuff: DS.hasMany('stuff', {async: true})
ember expect
{
user: { id: 1, stuff_id: [1, 2, 3] }
}
from emberfire.
As you found out, async: false
requires the server to sideload
the related records into the main payload. This is not something that firebase is capable of doing, thus, we only support async: true
or embedded: true
from emberfire.
Related Issues (20)
- This seems to throw an error HOT 2
- Realtime: how to subscribe to multiple documents HOT 15
- Steps for local-setup lead to non-functional dummy app HOT 2
- Does emberfire v3 realtime database adapter work at all? HOT 7
- store.queryRecord broken with query-only HOT 2
- Type Error: firebase-app.ts HOT 2
- Realtime Updates not working HOT 8
- fastboot, ember simple auth and emberfire dont work each other HOT 2
- error querying firestore in fastboot mode HOT 1
- Firestore adapter reference options order
- Emberfire v3 bug in the firestore adapter
- Bug in firestore: Cannot read property 'replace' of undefined HOT 5
- Using `include` in findRecord throws error HOT 1
- subcollections implemented in a way that prevents multiple hasmany relationships with the same model
- FirestoreAdapter Error while processing route: index the adapter could not find the resource HOT 2
- Session.isAuthenticated is not getting updated? HOT 5
- adapter.fetch is not a function when using TORII for Auth in 3.0.0-rc6 HOT 1
- Potential Security Issue
- @jamesdaniels, please consider ember-adopted-addons program HOT 1
- For Anyone Struggling with hasMany relationships with Firestore
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emberfire.