I have a sequelize code by using findOrCreate method like this:
const [user, created] = await Users.findOrCreate({
where: {
email: payload.email,
username: payload.username,
}, defaults: {
...payload,
}
});
code works properly when both email & username are exist in DB, it won't creating the table. but when I'm using different email but still using same username it will make my server instantly returns server code 500 with error message validation error. How do I to using this findOrCreate method by having 2 unique keys.