To update an element in an array field, you can use the positional $ operator
For example, the following js increments c from 3 to 4 for _id 341445:
db.collection.update({a:1, "b._id":341445} , {$inc:{"b.$.c":1}})
More Related Contents:
- ‘Field required a bean of type that could not be found.’ error spring restful API using mongodb
- What’s the difference between Spring Data’s MongoTemplate and MongoRepository?
- Making spring-data-mongodb multi-tenant
- How to do a Mongo aggregation query in Spring Data?
- Spring data mongodb – The ‘cursor’ option is required
- MongoDB $aggregate $push multiple fields in Java Spring Data
- spring-data-mongo – optional query parameters?
- How do you configure Embedded MongDB for integration testing in a Spring Boot application?
- How To Configure MongoDb Collection Name For a Class in Spring Data
- TransactionRequiredException Executing an update/delete query
- Filter invoke twice when register as Spring bean
- How to return a custom object from a Spring Data JPA GROUP BY query
- Spring MVC @PathVariable getting truncated
- POSTing a @OneToMany sub-resource association in Spring Data REST
- Spring @Autowired and @Qualifier [closed]
- Error : java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(I)V
- How to set spring active profiles with maven profiles
- How to conditionally enable or disable scheduled jobs in Spring?
- Spring hibernate template when to use and why?
- Spring Prototype scoped bean in a singleton
- How to run bootRun with spring profile via gradle task
- no suitable HttpMessageConverter found for response type
- Testing @Scheduled in spring
- java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
- java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.isInJavaLangAnnotationPackage(Ljava/lang/annotation/Annotation;)Z
- Spring Controller to handle all requests not matched by other Controllers
- Is there a way to specify a default property value in Spring XML?
- Jackson date-format for OffsetDateTime in Spring Boot
- java.lang.NoSuchMethodError when the method definitely exists
- Spring 3.2.x with Java 8