Result from querys undefined ?????

15 views
Skip to first unread message

Rudi Werner

unread,
Jul 14, 2016, 12:02:26 PM7/14/16
to Firebase + EmberJS
I am playing with emberFire / Ember Data but can't find why this code will not working ??? The var id_cust_ fb_cust is always undefined ? When i look in ember inspector the query's works fine ! What am i doing wrong ???

What comes back from .query ??? 


import Ember from 'ember';
export default Ember.Controller.extend({
 actions: {
     fixit: function() {
     var teller = 11;
     var _this = this;
     var strTeller = teller.toString();
    _this.store.findRecord('address',strTeller).then(function(address){
        var id_cust_presta_addr = address.get('id_customer');
        console.log('Id Customer Presta in address is :' + id_cust_presta_addr);
        _this.store.query('customer', {
                orderBy: 'id_customer',
                equalTo: id_cust_presta_addr
            }).then(function(customer){
                var id_cust_fb_cust = customer.get('email');
                console.log('Id Customer Presta in CUSTOMER is :' + id_cust_fb_cust + 'voor : ' + id_cust_presta_addr );
            })

    });
    } //fixit
} // actions

Tim Stirrat

unread,
Jul 14, 2016, 1:50:24 PM7/14/16
to Rudi Werner, Firebase + EmberJS
Hi Rudi,

The result of a store.query is a collection (DS.AdapterPopulatedRecordArray > Ember.ArrayProxy), so you can do something like the following:

this.store.query('customer', {orderBy: 'id_customer', equalTo: id_cust_presta_addr})
  .then(result => result.get('firstObject'))
  .then((customer) => {
    console.log('Customer email: ' + customer.get('email'));
  });

Hope that gives you something to work with.

Cheers,

Tim

--
You received this message because you are subscribed to the Google Groups "Firebase + EmberJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-embe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages