2017-06-01 57 views
0

要麼the docs是舊的或我誤解,或有一個錯誤。在任何情況下:續集 - 如何添加其他字段通過

const User = sequelize.define('user', {}) 
const Project = sequelize.define('project', {}) 
const UserProjects = sequelize.define('userProjects', { 
    status: Sequelize.STRING 
}) 

User.belongsToMany(Project, { through: UserProjects }) 
Project.belongsToMany(User, { through: UserProjects }) 

sequelize.sync().then(v => { 

    var user, project; 
    User.create({}).then(_user => { 
     user = _user; 

     Project.create({}).then(_project => { 
      project = _project; 
      // project.addUser(user, { through: { status: 'started' } }) 
      user.addProject(project, { through: { status: 'started' } }); 


     }) 
    }) 

}) 

以下應該創建一個與填充狀態字段的關聯,但它是空的。

我思念的東西

回答

相關問題