-
Notifications
You must be signed in to change notification settings - Fork 114
Associations
Matt Broadstone edited this page Jan 26, 2015
·
2 revisions
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
-
GETreturn a list of all students as json records -
POSTadds a new student to the list of all students -
PUT(not applicable) -
DELETE(not applicable)
/students/:studentId
-
GETreturn json record of student database item with id === :studentId -
POST(not applicable) -
PUTupdate student id record with posted json where id === :studentId -
DELETEdelete record from database where id === :studentId
/students/:studentId/courses
-
GETreturn all courses associated with a given student -
POSTadd a course to courses, and associate it with a given student -
PUT(not applicable) -
DELETE(not applicable)
/students/:studentId/courses/:courseId
-
GETreturn json record of a given courseId -
POST(not applicable) -
PUTupdate course with courseId -
DELETEdelete the course given by courseId