Home > Blockchain >  Update a string in an array mongoose
Update a string in an array mongoose

Time:03-23

I have a simple question lets say I have an array like numbers:[1,2,3]

And I want to search the whole collection and update every document that has in its numbers array the number 2

CodePudding user response:

 Collection.find({'numbers': { $in:numbers}}).update(
        {$push:{numbers:2}}
    )
  • Related