I am trying to update multiple records that meet specific condition using NodeJS and Sequelize. Example,if student_id is 1 and advisor_id is 1 then set score to 90 and if student_id is 1 and advisor_id is 2 then set score to 80 and so on .... Each of student is evaluated by 3 advisors. In my scores table I have id, student_id, advisor_id, score.
Below is an example JSON data which is passed by user.
{
"students": [
{
"student_id": 1,
"committee": [
{ "advisor_id": 1, "score": 90 },
{ "advisor_id": 2, "score": 80 },
{ "advisor_id": 3, "score": 90 },
]
},
{
"student_id": 2,
"committee": [
{ "advisor_id": 1, "score": 70 },
{ "advisor_id": 2, "score": 70 },
{ "advisor_id": 3, "score": 80 },
]
},
{
"student_id": 3,
"committee": [
{ "advisor_id": 1, "score": 90 },
{ "advisor_id": 2, "score": 70 },
{ "advisor_id": 3, "score": 70 },
]
},
{
"student_id": 4,
"committee": [
{ "advisor_id": 1, "score": 80 },
{ "advisor_id": 2, "score": 90 },
{ "advisor_id": 3, "score": 80 },
]
},
]
}