hasAndBelongsToMany - intermediary (mapping) table

6 views
Skip to first unread message

Mike

unread,
Aug 11, 2011, 3:26:25 PM8/11/11
to JazzRecord
When using hasAndBelongsToMany is there a method for adding additional
data to the intermediary (mapping) table?

For instance from the example you provide of student and high school
class if you wanted to store the date enrolled, date completed, or
grades wouldn't they most likely be stored in the joining (mapping)
table?

var HighSchoolClass = new JazzRecord.Model({
table: "high_school_classes",
foreignKey: "high_school_class_id",
hasAndBelongsToMany: { students: "students"},
columns: {
name: "text",
room: "number"
}
});

var Student = new JazzRecord.Model({
table: "students",
foreignKey: "student_id",
belongsTo: { home: "homes"},
hasAndBelongsToMany: { classes: "high_school_classes"},
columns: {
name: "text",
grade: "text",
home_id: "number"
}
});

Nick Carter

unread,
Aug 18, 2011, 4:49:08 PM8/18/11
to jazzr...@googlegroups.com
The only way to accomplish this right now is to provide two separate hasMany models that each point to the same (manually created) mapping/intermediary table, which would be handled via a model of some kind, such as maybe StudentClassData. This same issue cropped up in Rails HABTM years ago.
Reply all
Reply to author
Forward
0 new messages