Home > Software design >  Change the boolean value of 'available' Array (e.g at index 4 which taken from user input
Change the boolean value of 'available' Array (e.g at index 4 which taken from user input

Time:11-03

Please see the image below:

enter image description here

CodePudding user response:

use update like this

db.collection.update({},
{
  $set: {
    "available.3": false // index 3 means element number 4
  }
})

if you are using mongoose your query is like this

Model.update({}, // model name instead of Model
{
  $set: {
    "available.3": false // index 3 means element number 4
  }
})

https://mongoplayground.net/p/cMWOtIw5L_J

  • Related