gpt4 book ai didi

Node.js + Sequelize : two foreign keys of the same model

转载 作者:行者123 更新时间:2023-12-03 22:39:57 25 4
gpt4 key购买 nike

我需要在一个名为 DataSurvey 的模型中添加两​​个外键,它们指向另一个名为 AppPerson 的模型

  DataSurvey.associate = function(models) {
DataSurvey.belongsTo(models.AppPerson); // this should have the name idResponsible
DataSurvey.belongsTo(models.AppPerson); // this should have the name idConcerned };

我怎样才能做到这一点?

感谢您的帮助

最佳答案

这工作正常

    DataSurvey.belongsTo(models.AppPerson, {as: 'Responsible'});
DataSurvey.belongsTo(models.AppPerson, {as: 'Concerned'});

关于Node.js + Sequelize : two foreign keys of the same model,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50642994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com