Answers for "mongoose update object in array two level down"

1

mongoose update array push multiple

Kitten.update(
  { name: 'fluffy'},
  {
    $push: {
      values: {
        $each: [2, 3]
      }
    }
  }
)
  .then(result => {
  	console.log(result)
  })
  .catch(err => {
    console.error(err)
  })
Posted by: Guest on March-23-2021
-1

mongoose update array in object

Person.findOneAndUpdate({_id: id}, 
{ 
  "$set": {[`items.$[outer].${propertyName}`]: value} 
},
{ 
  "arrayFilters": [{ "outer.id": itemId }]
},
function(err, response) {
  ...
})
Posted by: Guest on January-11-2021

Code answers related to "mongoose update object in array two level down"

Code answers related to "Javascript"

Browse Popular Code Answers by Language