[JAVA-3228] Watch with project pipeline didn't work correctly. Created: 15/Mar/19 Updated: 27/Oct/23 Resolved: 04/May/19 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Change Streams |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Han | Assignee: | Ross Lawley |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
I am using mongo java drivers as below:
When I define a simple pipeline as:
After my doing some CRUD operations, I always get these 'null' output:
Did not it should be like :
Please correct me.
|
| Comments |
| Comment by Han [ 06/Jun/19 ] | ||||||||||
|
I have created one in the SERVER project. Thanks, Ross. | ||||||||||
| Comment by Ross Lawley [ 05/Jun/19 ] | ||||||||||
|
Hi jiehan2019, The driver only returns what is provided by the server. You are welcome to introspect it and convert the data to the format as needed or alternatively create a feature request in the SERVER project. Ross | ||||||||||
| Comment by Han [ 05/Jun/19 ] | ||||||||||
|
Yang model instance is transformed into json and then to document which is to be saved in MongoDB | ||||||||||
| Comment by Han [ 05/Jun/19 ] | ||||||||||
|
Hi @Ross Lawley, Here are outputs for corresponding steps, What I need is to manipulate the deleted array item, but it seems not workable. 1) First , here is the initial data in the database, there're 3 outer array items "test-0, test-1, test-2" with each has 3 inner array items "nest-test-0,nest-test-1,nest-test-3":
2) Next , I pull one nested array item by calling 'collection.updateOne(...)' where 'Update' and 'UpdateOptions' like:
It's clear above that I specify the '$[item0]' with 'Filter{fieldName='item0.name', value=test-0}' to delete the inner array item 'nest-test-2' from outer array item 'test-0'. 3) After step 2), finally I recieve the change event:
From the output we can see that it's an 'update' operation type and the 'updatedFields' is :
Note 'updatedFields' above just provides data after '$pull', but I really need to see detail deleted data information "what I delete from where", an idealy output I would prefer is like kind of :
In this way , with 'array-filter' and 'pulled' fields, I could get the deleted data and notify listeners just like 'DataTreeChangeService' does:
| ||||||||||
| Comment by Ross Lawley [ 26/Apr/19 ] | ||||||||||
|
Hi jiehan2019, The ChangeStreamDocument is a POJO and not a flexible map like document. If you are going to manipulate the output of the Change Stream then please use the ChangeStreamIterable#withDocumentClass:
That will provide the change stream documents as provided by the server and should fix the issue you are seeing. Please let me know if that works for you. Ross | ||||||||||
| Comment by Han [ 26/Apr/19 ] | ||||||||||
|
Hi @Jeff Yemin Sorry for late comments when I fould this issue was closed: yes, I called like 'collection.watch(pipeline).fullDocument(FullDocument.UPDATE_LOOKUP))', and I have been working on my project which I need to adapt MongoDB stream to DataTreeChangeService: https://wiki.opendaylight.org/view/Project_Proposals:Alt-datastores#DataTreeChangeService But now it seems that I cannot resolve issues mentioned in the paragraph above correctly. | ||||||||||
| Comment by Jeffrey Yemin [ 29/Mar/19 ] | ||||||||||
|
Hi jiehan2019 Do you mean to say that if you call it the way you indicate in your last comment, it works as expected? | ||||||||||
| Comment by Han [ 15/Mar/19 ] | ||||||||||
|
call as: collection.watch(pipeline) |