小编far*_*afi的帖子

SequelizeUniqueConstraintError:验证错误

我正在使用sequelize 和node.js。我有一列想要将其类型更改为唯一,当我想要运行迁移时,我遇到了这个错误,我该如何解决它?

ERROR: SequelizeUniqueConstraintError: Validation error
Run Code Online (Sandbox Code Playgroud)

这是我的代码:


up: (queryInterface, Sequelize) => {
    return Promise.all([
      queryInterface.changeColumn('PersonalInfo', 'ssn', {type: Sequelize.STRING, unique: true
      }),
      queryInterface.changeColumn('PersonalInfoDraft', 'ssn', {type: Sequelize.STRING, unique:true
      })
    ])
  }
Run Code Online (Sandbox Code Playgroud)

migration unique node.js sequelize.js

3
推荐指数
1
解决办法
7114
查看次数

如何在续集中连接列?

我正在使用sequelize 和node.js。我想将 PrimaryPractice 模型的列值相互连接。我怎么解决这个问题?这是我的代码:

ProviderPayer.findAll({
                  where: {
                      orgPayerId: {
                          [Op.in]: orgPayerIds
                      }
                  },
                  attributes: ["effective_date"],
                  include: [{
                          model: PayerTracks,
                          attributes: ["title"],
                          as: "payers",
                      },
                      {
                          model: User,
                          where: {
                              id: {[Op.in]: userIds},
                              deletedAt: null,
                              status: {[Op.ne]: STATUS.INACTIVE}
                          },
                          attributes: ["id"],
                          include: [
                              {
                                  model: PrimaryPractice,
                                  as: "primaryPractice",
                                  attributes: [
                                   "addressStreetPrimPract", 
                                   "addressStreet2PrimPract", 
                                   "addressCityPrimPract", 
                                   "addressStatePrimPract", 
                                   "addressZipPrimPract"]
                              }
                          ]
                      }

                  ]
              })
Run Code Online (Sandbox Code Playgroud)

node.js sequelize.js

2
推荐指数
1
解决办法
3579
查看次数

标签 统计

node.js ×2

sequelize.js ×2

migration ×1

unique ×1