Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

edit mongodb array if checkbox is checked

//////////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)
    },
Comment

PREVIOUS NEXT
Code Example
Javascript :: Make React Tooltip work for dynamic elements 
Javascript :: how to import images from public folder in react js 
Javascript :: migration mongoose nestjs 
Javascript :: date et heure javascript 
Javascript :: && in javascript new 
Javascript :: click outside button angular 
Javascript :: send data to javscript 
Javascript :: joining two array 
Javascript :: Backbon events In View 
Javascript :: Ghost-Blog Maria DB Issue 
Javascript :: actual jquery 
Javascript :: Change Name Of Function Constructor 
Javascript :: changetypeprofiles 
Javascript :: discord.js Function to replace certain characters with a pattern 
Javascript :: converting JSON to jsObject 
Javascript :: Return object in parenthesis to avoid it being considered a wrapping function body 
Javascript :: Backbone Sync Example 
Javascript :: javascript get css property 
Javascript :: select 2 is not working in nodejs 
Javascript :: how to get header in node controller 
Javascript :: save input local storage react 
Javascript :: regex remove whitespace 
Javascript :: convert bytes to kb or mb javascript 
Javascript :: linux Error HH604: Error running JSON-RPC server 
Javascript :: find the minimum number in an array javascript 
Javascript :: menu with dynamic submenu in javascript 
Javascript :: javascript split string into groups of n 
Javascript :: javascript complex literal 2 
Javascript :: svelte function at interval 
Javascript :: Plumasil - new item button text 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =