观看项目管道无法正常工作

时间:2019-03-18 01:24:02

标签: mongodb pipeline watch

我正在使用mongo java驱动程序,如下所示:

<dependency>
  <groupId>org.mongodb</groupId>
  <artifactId>mongo-java-driver</artifactId>
   <version>3.10.1</version>
</dependency>
<dependency>
  <groupId>org.mongodb</groupId>
  <artifactId>mongodb-driver-reactivestreams</artifactId>
  <version>1.11.0</version>
</dependency>

当我将简单的管道定义为:

List<Bson> pipeline = Arrays.asList(
    Aggregates.project(Projections.fields(
        Projections.computed("id", "$fullDocument._id")
    ))
);

collection.watch(pipeline).fullDocument(FullDocument.UPDATE_LOOKUP));

在执行了一些CRUD操作之后,我总是得到以下“空”输出:

    ChangeStreamDocument{resumeToken={"_data": "825C8B65510000000129295A1004E2034BD33C7D40DE92CB94E139C92CB146645F696400645C8B65511B2DF1941FD846250004"}, namespace=null, fullDocument=null, documentKey=null, clusterTime=null, operationType=null, updateDescription=null}
    ChangeStreamDocument{resumeToken={"_data": "825C8B65510000000229295A1004E2034BD33C7D40DE92CB94E139C92CB146645F696400645C8B65511B2DF1941FD846250004"}, namespace=null, fullDocument=null, documentKey=null, clusterTime=null, operationType=null, updateDescription=null}
    ChangeStreamDocument{resumeToken={"_data": "825C8B65560000000129295A1004E2034BD33C7D40DE92CB94E139C92CB146645F696400645C8B65511B2DF1941FD846250004"}, namespace=null, fullDocument=null, documentKey=null, clusterTime=null, operationType=null, updateDescription=null}
    ChangeStreamDocument{resumeToken={"_data": "825C8B65560000000229295A1004E2034BD33C7D40DE92CB94E139C92CB146645F696400645C8B65511B2DF1941FD846250004"}, namespace=null, fullDocument=null, documentKey=null, clusterTime=null, operationType=null, updateDescription=null}
    Did not it should be like :

    {
        "id": xxxxxxxxxx
    }

请纠正我。

0 个答案:

没有答案