this posting is in line with the role of modules at Node.js project
when in comes to update data to database, we would use sequelize update method or SQL raw query. either way would need update values and conditions to conduct operation.
then where could we set update values and conditions?
let us see two different style of update
// model.js
async putMemberSnsVisible(transaction, updateInfo, memberFilter) {
try {
const result = await MemberSns.update(
{
[1] is_visible: updateInfo.is_visible
},
{
where: { users_id: memberFilter.memberId, type: updateInfo.code },
transaction: transaction
}
)
return result
} catch (err) {
throw new Error(`[EA501] MemberModel.putMemberSnsVisible with error: ${err}`)
}
}
// model.js
async putMemberSnsVisible(transaction, updateInfo, memberFilter) {
try {
const result = await MemberSns.update(
[1] updateInfo, {
where: { users_id: memberFilter.memberId, type: updateInfo.code },
transaction: transaction
}
)
return result
} catch (err) {
throw new Error(`[EA501] MemberModel.putMemberSnsVisible with error: ${err}`)
}
}
case_1.[1] : set update value at the model.js level and update the assigned data from
updateInfo
(Object)
case_2.[1] : set update value at the core.js level and update any kind of data inupdateInfo
(Object)
in project as a intergration of modules in which each module has its distinguished role, case_2 would be more ideal to the modulized project