Relations in sqlize / hasOne does not work
<p>I am trying to create 1:1 relation between table of shops and product.
Each product should have an foreign key of shop table and each shop should have foreign key of product.</p>

<p>i have defined those two tables.</p>

<pre><code>module.exports = function( sequelize , DataTypes ){
    var shops = sequelize.define('shops',{
            id: {
                type: DataTypes.INTEGER,
                allowNull:false,
                primaryKey:true,
                autoIncrement:true
            },
            name:{
                type:DataTypes.STRING,
                allowNull:false
            },
            address:{
                type: DataTypes.STRING,
                allowNull:false
            },
            web:{
                type: DataTypes.STRING,
                allowNull:false
            },
            price:{
                type: DataTypes.INTEGER,
                allowNull:false
            }
    })
    return shops
}
</code></pre>

<p>`</p>

<p>var shop = require('./shops.js');</p>

<pre><code>module.exports = function( sequelize , DataTypes ){
    var component = sequelize.define('component',{
            id: {
                type: DataTypes.INTEGER,
                allowNull:false,
                primaryKey:true,
                autoIncrement:true
            },
            name:{
                type: DataTypes.STRING,
                allowNull:false
            },
            storage:{
                type: DataTypes.INTEGER,
                allowNull:false
            },
            bilance:{
                type: DataTypes.INTEGER,
                allowNull:false
            }
    },{
        classMethods:{
         associate:function(models){
          component.hasOne(shop,{foreignKey:'foreign_key'})
         }
        }
    })
    return component;
}
</code></pre>

<p>inside db.js file a connected it using.</p>

<pre><code>db.shop.belongsTo(db.component)
db.component.hasOne( db.shop ,{foreignKey : 'shop_id'})
</code></pre>

<p>but this added componentId {foreign key} and shop_id another foreign key ,both of them to the shop table.</p>

<p>If i replace 1:1 relation if 1:n e.g</p>

<pre><code>db.component.hasMany(..)
</code></pre>

<p>It does the same thing , adds both foreign keys into the shops table</p>