How to use updateOption with arrayFilters in spring-data mongodb?

后端 未结 2 2039
误落风尘
误落风尘 2021-01-03 01:35

I have a document as shown below in Mongodb:

Now, I want to go to a document based on specific \"_id\" and for that document, want to go to \"schedu

2条回答
  •  没有蜡笔的小新
    2021-01-03 01:43

    It will soon be available in spring-data-mongodb. See : https://github.com/spring-projects/spring-data-mongodb/pull/656

    Using it will look like :

    new Update()
    .set("grades.$[element]", 100)
    .filterArray(Criteria.where("element").gte(100));
    

    In the meantime, you should be able to use it with their snapshot maven repository:

    
      org.springframework.data
      spring-data-mongodb
      2.2.0.DATAMONGO-2215-SNAPSHOT
    
    
    
      spring-libs-snapshot
      Spring Snapshot Repository
      https://repo.spring.io/libs-snapshot
    
    

提交回复
热议问题