Edit MongoDB Array Jika kotak centang dicentang
//////////NODE BACKEND
router.post("/deletePurposOfDating", async (req, res) => {
const { email, goal } = req.body
try {
let user = await User.updateOne({ email }, { $pull: { goal } })
res.status(200).json({
message: "Update successful",
success: true,
user,
})
} catch (error) {
return res.status(401).json({
success: false,
message: "Update failed",
error,
})
}
})
////////////FRONTEND VUE METHOD
setPurpose(select, i) {
let myCheckbox = document.querySelectorAll(
`.myCheckbox .vs-checkbox-con [type='checkbox']`
)[i]
if (myCheckbox.checked)
this.$store.dispatch("updatePurposeOfDating", select)
else this.$store.dispatch("deletePurposOfDating", select)
},
Rukkiecodes