mercredi 9 mars 2016

Ember get request

I am making an app using MongoDB, Ember, Express and Node.

My grade model is defined as follows:

export default DS.Model.extend({
    mark: DS.attr(),
    section: DS.attr(),
    student: DS.belongsTo('student', { async: true }),
    coursecode: DS.belongsTo('coursecode', { async: true }),
    programrecord: DS.belongsTo('programrecord', { async: true })
});

And my student model is defined as follows:

export default DS.Model.extend({
  number: DS.attr(),
  firstName: DS.attr(),
  lastName: DS.attr(),
  DOB: DS.attr(),
  resInfo: DS.belongsTo('residency',{ async: true }),
  gender: DS.belongsTo('gender',{ async: true }),
  country: DS.belongsTo('country',{ async: true }),
  province: DS.belongsTo('province',{ async: true }),
  city: DS.belongsTo('city',{ async: true }),
  grades: DS.hasMany('grade', { async: true }),
});

I am making a get request to query for all grades that have a specific mark:

GET to /grades?mark=100 

I am also making a get request to query for grades that belong to a specific student (not sure if I am doing this correctly, I am passing in the ID of the student object):

GET to /grades?student=56d33a7896c31b6b1e40446a

How do I define the route in the server.js file to respond to this so I can return ONLY the grade objects with a mark of 100 or alternatively, return only the grade object that belongs to a student?




Aucun commentaire:

Enregistrer un commentaire