Is there a shortcut in Sequelize for “user.setGroups()” when I have all the group ids?
问题 In Sequelize, if I have a simple parent-child relationship I can set the foreignKey column without the whole object: Chapter.belongsTo(Book); // this works, but I had to query the DB for the 'book' object return Chapter.create({title: 'The Title'}).then(function(chapter) { return chapter.setBook(book); } The above generates two SQL statements, one to INSERT into the chapters table and one to UPDATE the foreignKey. // this also works, if I happen to know the book ID already return Chapter