2017-08-27 557 views
1

Test1:在电子邮件属性中添加“unique:true”。Sequelize“unique:true”使用不同的键名将两次相同的唯一键KEYENCE

Test2:在电子邮件属性中添加“unique:{args:true,msg:”xxxxxx“}”。

使用Sequelize:4.7.5 & MySQL的:19年7月5日

我期待会有两个测试用例一个指标。

但是我得到两个索引的Test1。两个索引都有同列,但不同关键字

这是一个错误还是我做错了什么?

尝试下面的模型defs。

Test1 = { 
id: { 
    type: Sequelize.INTEGER.UNSIGNED, 
    primaryKey: true, 
    autoIncrement: true 
}, 

emailId: { 
    type: Sequelize.STRING, 
    unique: true, 
    allowNull: false, 
    validate: { 
     isEmail: { 
      args: true, 
      msg: 'Invalid email id.' 
     } 
    } 
} 
} 


Test2 = { 
id: { 
    type: Sequelize.INTEGER.UNSIGNED, 
    primaryKey: true, 
    autoIncrement: true 
}, 

emailId: { 
    type: Sequelize.STRING, 
    unique: { 
     args: true, 
     msg: 'This email id is already registered.' 
    }, 
    allowNull: false, 
    validate: { 
     isEmail: { 
      args: true, 
      msg: 'Invalid email id.' 
     } 
    } 
} 
} 

回答

相关问题