SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
805 stars 171 forks source link

_Id filtered change streams are not fired after a PATCH request on the certain document #372

Closed shireefadel closed 4 years ago

shireefadel commented 4 years ago

If I created a change stream with _match stage to filter streams based on certain document with certain _id, it works fine with POST requests, but if I needed to update certain properties for a document with PATCH request the stream not fired.

Expected Behavior

Change stream message to be received if a change occur using a PATCH request on the filtered document.

Current Behavior

Change stream message NOT received if a change occur using a PATCH request on the filtered document.

Context

If I depend on POST requests to make a change on a document, the Change Event of the change stream will not contain any updateDescription information as in case of POST request the operationType is replace not update, that is why I have to use PATCH because it's actually make a real update not replace, but in that case, the filtered stream will not fire.

Environment

Steps to Reproduce

  1. Create a stream with the following info { "streams" : [ { "stages" : [ { "_$match" : { "fullDocument::_id" : { "_$var" : "n" } } } ], "uri" : "changestream" } , { "stages" : [], "uri" : "changestream2" } ] }
  2. using any tool like firecamp to test your streams using WebSokets and start to listen for changes on a certain document like the following ws://username:pass@server/db/collection/_streams/changestream?avars={'n': ObjectId("5ddf5e4e29f485c946fde3a4")}
  3. make any PATCH request for document the same document above 5ddf5e4e29f485c946fde3a4

Possible Implementation

ujibang commented 4 years ago

Fixed in RESTHeart Platform version 4.1.11