Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4826

No get request for related model

$
0
0

@Gen wrote:

I’m new to ember, so i’ll apologize in advance if my problem is extremely obvious. I related my two models, pat and txplan on a belongsTo / hasMany relationship, and I’m not seeing a get request being made to the related model. As I’m receiving no errors, I’m not seeing what the issue is. Any suggestions would be much appreciated!

model/pat

const {
attr,
hasMany
} = DS;

export default DS.Model.extend({

  txplan: hasMany('txplan', { async: true }),

  pat: attr('number'),
  fname: attr('string'),
  lname: attr('string'),
  birthdate: attr('date'),
  email: attr('string'),
  imagefolder: attr('string')
 
});

model/txplan

const {
attr,
belongsTo
} = DS;

export default DS.Model.extend({

  pat: belongsTo('pat', { async: true }),

  treatmentplannum: attr('number'),
  heading: attr('string'),
  dateTP: attr('date'),
  proccode: attr('string'),
  descript: attr('string'),
  
});

route

import Route from '@ember/routing/route';

export default Route.extend({
  model(params) {
   return this.store.query('pat', {pat : params.pat})
 }
});

template

{{#each model as |pat|}}
{{pat.pat}}
{{pat.txplan.heading}}
{{/each}}

get /txplan

{  
   "txplan":[  
      {  
         "id":1,
         "treatplannum":3,
         "pat":1,
         "heading":"test",
         "dateTP":"2018-02-23T08:00:00.000Z",
         "proccode":"T4528"             
           },

get /pats

{  
   "pats":[  
      {  
         "id":1,
         "pat":1,
         "fname":"Test",
         "lname":"User",
         "birthdate":"12-22-1960",
         "email":"test@gmail.com",
         "imagefolder":"TestUser1",
        },

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles