Sequelize insert into join table (many-to-many)
2019+
After Sequelize 5+, findById()
is replaced by findByPk()
Ledger.findByPk(22).then(ledger=>{
ledger.setCoins([1,2]).then(sc=>{
console.log(sc);
});
});
Well, I solved the problem with setCoins
, above. Apparently it takes id numbers and not objects, so this works:
Ledger.findById(22).then(ledger=>{
ledger.setCoins([1,2]).then(sc=>{
console.log(sc);
});
});
I'd still like to understand includes and associations better, though.