thrownewError("Naming collision between attribute '"+this.as+"' and association '"+this.as+"' on model "+this.source.name+'. To remedy this, change either foreignKey or as in your association definition');
thrownewError("Naming collision between attribute '"+this.as+"' and association '"+this.as+"' on model "+this.source.name+'. To remedy this, change either foreignKey or as in your association definition');
thrownewError("Naming collision between attribute '"+this.as+"' and association '"+this.as+"' on model "+this.source.name+'. To remedy this, change either foreignKey or as in your association definition');
thrownewError("Naming collision between attribute '"+assocition.as+"' and association '"+assocition.as+"' on model "+assocition.source.name+'. To remedy this, change either foreignKey or as in your association definition');
@@ -36,25 +36,25 @@ var Utils = require('./../utils')
* ]
* })
* ```
* To get full control over the foreign key column added by sequelize, you can use the `foreignKey` option. It can either be a string, that specifies the name, or and object type definition,
* equivalent to those passed to `sequelize.define`.
* To get full control over the foreign key column added by sequelize, you can use the `foreignKey` option. It can either be a string, that specifies the name, or and object type definition,
* equivalent to those passed to `sequelize.define`.
*
* ```js
* User.hasMany(Picture, { foreignKey: 'uid' })
* ```
*
* User.hasMany(Picture, { foreignKey: 'uid' })
* ```
*
* The foreign key column in Picture will now be called `uid` instead of the default `userId`.
*
*
* ```js
* User.hasMany(Picture, {
* foreignKey: {
* fieldName: 'uid'
* allowNull: false
* allowNull: false
* }
* })
* ```
*
* This specifies that the `uid` column can not be null. In most cases this will already be covered by the foreign key costraints, which sequelize creates automatically,
*
* This specifies that the `uid` column can not be null. In most cases this will already be covered by the foreign key costraints, which sequelize creates automatically,
* but can be usefull in case where the foreign keys are disabled, e.g. due to circular references (see `constraints: false` below).
*
* When fetching associated models, you can limit your query to only load some models. These queries are written in the same way as queries to `find`/`findAll`. To only get pictures in JPG, you can do:
...
...
@@ -93,6 +93,31 @@ var Utils = require('./../utils')
*/
varMixin=module.exports=function(){};
// The logic for hasOne and belongsTo is exactly the same
varsingleLinked=function(Type){
returnfunction(targetModel,options){
if(!(targetModelinstanceofthis.sequelize.Model)){
thrownewError(this.name+"."+Utils._.lowercaseFirst(Type.toString())+" called with something that's not an instance of Sequelize.Model");
}
varsourceModel=this;
// Since this is a mixin, we'll need a unique variable name for hooks (since Model will override our hooks option)