如何在spring-data mongodb中将updateOption与arrayFilters一起使用? [英] How to use updateOption with arrayFilters in spring-data mongodb?

查看:371
本文介绍了如何在spring-data mongodb中将updateOption与arrayFilters一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mongodb中有一个文档,如下所示:

I have a document as shown below in Mongodb:

现在,我要转到基于特定"_id"的文档,对于该文档,要转到时间表"列表,其中列出了几个特定的​​日期(不仅是一个日期,而且还有多个日期) ),我想将状态更新为"BOOKED".我通过此链接, 如何使用带有arrayFilters的已过滤位置运算符来应用更新 但是在MongoTemplate类中,updateMulti方法不采用updateOption参数.有人可以帮忙

Now, I want to go to a document based on specific "_id" and for that document, want to go to "schedule" list in which for the few specific dates (not only one date, but more than one), I want to update the status as "BOOKED".I went through this link, How to apply update using Filtered positional operator with arrayFilters but in MongoTemplate class, updateMulti method does NOT take the updateOption parameter. Can someone please help

我出去.真的很感谢任何建议.谢谢.

Me out. really will be appreciated for any suggestion. Thanks.

注意:我正在使用spring-data版本"2.0.3.RELEASE",MongoDB驱动程序版本是v3.6.4.

Note: I am using spring-data version "2.0.3.RELEASE", MongoDB driver version is v3.6.4.

下面是一个文档:

{
      "_id": "x1",
      "timeZone": "America/Los_Angeles",
      "schedule": [
        {
          "Date": "2018-07-10T00:00:00.000Z",
          "status": "AVAILABLE"
        },
        {
          "Date": "2018-07-10T00:30:00.000Z",
          "status": "AVAILABLE"
        },
        {
          "Date": "2018-07-10T08:00:00.000Z",
          "status": "AVAILABLE"
        }
      ],
      "_class": "com.scheduler.persistance.model.Calendar"
    }

推荐答案

它将很快在spring-data-mongodb中可用.参见: https://github.com/spring-projects/spring- data-mongodb/pull/656

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

使用它将类似于:

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

同时,您应该可以将其与快照maven存储库一起使用:

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

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-mongodb</artifactId>
  <version>2.2.0.DATAMONGO-2215-SNAPSHOT</version>
</dependency>

<repository>
  <id>spring-libs-snapshot</id>
  <name>Spring Snapshot Repository</name>
  <url>https://repo.spring.io/libs-snapshot</url>
</repository>

这篇关于如何在spring-data mongodb中将updateOption与arrayFilters一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆