Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

mongodb increment array item

 await Model.findOneAndUpdate({
   id: postId,
   'array.id': itemId
 }, {
   $inc: {
   	  'array.$.some_field': -1
   }
 })
 
PREVIOUS NEXT
Tagged: #mongodb #increment #array #item
ADD COMMENT
Topic
Name
6+8 =