lundi 31 juillet 2017

Not retrieving any information from model using Ember.js using query() method

I'm trying to learn Ember.js by building a web application using the framework for the front end and node.js for the backend as well as mongoDB as a database.

I am using/attempting to use the url to feed in a parameter id and then query on that id.

I am having trouble grabbing the information from my model. My query works fine when I am using findAll(). However, when I switch to find() or query() I can't retrieve any results.

All the documentation I have looked at use different syntax that I have tried but none have worked.

I would greatly appreciate any hint or input. Thank you.

app/router.js

    Router.map(function() {
      this.route('stock', { path: '/:stock_id' });
    });

app/routes/stock.js

    export default Ember.Route.extend({
       model: function(params) {
         this.store.query('stock', {filter:{id : params.stock_id}}).then(function(stock){return stock.get('firstObject')});
       }
    });

app/models/stock.js

    export default DS.Model.extend({
       Symbol: DS.attr('string'),
       Name: DS.attr('string'),
       LastSale: DS.attr('string'),
       MarketCap: DS.attr('string'),
       IPOyear: DS.attr('string'),
       Industry: DS.attr('string')
    });

app/serializers/stock.js

    export default DS.RESTSerializer.extend({
       primaryKey: '_id',
       serializeId: function(id) {
          return id.toString();
       }
    });

app/templates/stock.hbs

   
   <h3></h3>
   




Aucun commentaire:

Enregistrer un commentaire