sequelize/sequelize — pull request #877 by janmeier (2013-09-03 14:11:19+00:00)
Title: Support for has many through / jointable model

This pull request adds support for specifying a model to use as the join table when doing double linked has-many associations, as described in #254

The join table is specified by adding a joinTableModel, which should be an instance of DAOFactory to the options when calling hasMany. The model only comes into effect after the second call (before that we don't know whether this is actually a double linked has many. Writing this code has led me to think that associations should be refactored for 2.0.0, so we can implicitly call hasManyDouble or something like that, instead of calling hasMany twice)

Some questions that I am not quite sure about regarding the code:
* Right now, when adding an association, there are two posibilites for adding data to the join table model - one is to add a property to the object that is being associated, and the other is to pass an extra argument to the addAssociation call. Should we really support both ways, or only one?
* When adding multiple associations with setAssociations you can again both set the join table attributes on the actual model that is being associated, or you can specify an extra argument with the values. Since we are associating multiple values, we need to be able to specify individual join table attributes for each, so here we need to support a property on each object. I chose to add an extra argument with "default values", so the user doesn't have to set the same attributes on each object - do you like this?