Skip to content
Matt Broadstone edited this page Jan 26, 2015 · 2 revisions

Associations

Given the models:

var Student = sequelize.define('student', { name: { type: DataTypes.STRING } }),
    Course = sequelize.define('course', { name: { type: DataTypes.STRING } });

Student.hasMany(Course);
Course.hasMany(Semester);

The following routes will be created:

/students

  • GET return a list of all students as json records
  • POST adds a new student to the list of all students
  • PUT (not applicable)
  • DELETE (not applicable)

/students/:studentId

  • GET return json record of student database item with id === :studentId
  • POST (not applicable)
  • PUT update student id record with posted json where id === :studentId
  • DELETE delete record from database where id === :studentId

/students/:studentId/courses

  • GET return all courses associated with a given student
  • POST add a course to courses, and associate it with a given student
  • PUT (not applicable)
  • DELETE (not applicable)

/students/:studentId/courses/:courseId

  • GET return json record of a given courseId
  • POST (not applicable)
  • PUT update course with courseId
  • DELETE delete the course given by courseId
Clone this wiki locally