How to specify async belongsTo/hasMany relationships in emberfire/emder-data?

前端 未结 1 1632
孤街浪徒
孤街浪徒 2021-01-29 04:59

I am very new at Ember/ED/EmberFire so apologies if this is a trivial question. I am able to save records to Firebase but I am unable to specify relationships to those records i

1条回答
  •  醉话见心
    2021-01-29 05:49

    this.store.find('patient', '-Jl8u8Tph_w4PMAXb9H_') returns a promise.

    Try this:

    this.store.find('patient', '-Jl8u8Tph_w4PMAXb9H_').then(function(pat) {
         var newEncounter = this.store.createRecord('encounter', {
            dateOfEncounter: this.get('dateOfEncounter'),
            patient: pat       
         });
    
         newEncounter.save();
    });
    

    0 讨论(0)
提交回复
热议问题