Git Product home page Git Product logo

Comments (9)

aputinski avatar aputinski commented on May 14, 2024

@yial2 without async: true the comments will not be fetched when store.find('post', 'post_id') is called

from emberfire.

yial2 avatar yial2 commented on May 14, 2024

@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.

aputinski avatar aputinski commented on May 14, 2024

@yial2 that's strange, I'll take a look and see what's going on.

from emberfire.

joelataylor avatar joelataylor commented on May 14, 2024

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.

aputinski avatar aputinski commented on May 14, 2024

@joelataylor

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.

joelataylor avatar joelataylor commented on May 14, 2024

@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.

williamli avatar williamli commented on May 14, 2024

regarding this and #108
am i correct to say that a async: false does not mean the data is eager loaded automatically?

from emberfire.

williamli avatar williamli commented on May 14, 2024

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.

tstirrat avatar tstirrat commented on May 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.