i have a relation Many to Many to do relation between Tournaments and Payers. So i have 3 models :
My question is : how to do to update this field 'status' ?
I tried this, but is wrong !!!
const participation = await Participant.findAll({
where: {
user_id: userId,
tournament_id: tournamentId,
},
});
await participation.update({ state: 'accepted' });
I am not sure this is the reason. But I assume that you shouldn't use the findAll method for your purpose.
findAll returns instance array, but update method belongs the model instance.
There are some possible solutions, I guess.
const participation = await Participant.findOne({ where: { user_id: userId, tournament_id: tournamentId });
participation.map((p) => p.update({ state: 'accepted' });
await Participant.update({ state: 'accepted' }, { where: { user_id: userId, tournament_id: tournamentId };
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.