hasOne hasMany problem

17 views
Skip to first unread message

Maxime

unread,
Nov 3, 2017, 4:36:27 AM11/3/17
to Sequelize
Hi,

I have a problem with two method hasOne and hasMany. 

I have two tables : Driver and Ad

Driver has hasOne(Ad) association

My code :

      let driver = await models.Driver.findById(3, {
        include: [{
          model: models.Ad
        }]
      });

driver.createAd({ 
  message: "HELLO"
});


Why i can create many Ad but association is hasOne ?

The FK driver_id is not unique !

An idea ?

Sorry for my english
Reply all
Reply to author
Forward
0 new messages