restheart icon indicating copy to clipboard operation
restheart copied to clipboard

[ChangeStream]

Open trappa92 opened this issue 6 months ago • 3 comments

Brief overview

In ChangeStream definition, we can define filters, but can we also define projections? Ideally, need to have the possibility to pass a list of projections as parameter (like "avars" for filters) and have same mecanism with optional variables via "ifvar"

Thanks

trappa92 avatar Feb 10 '24 06:02 trappa92

Hi @trappa92 ,

yes ✅ you can modify the change stream output using pipeline stages including $project, see https://www.mongodb.com/docs/manual/changeStreams/#modify-change-stream-output

And yes ✅, you can use ?avar to pass variables to the change stream, see Passing Variables to Change Stream. Starting with RESTHeart 7.6, the change stream definition can use optional stages, see Optional Stages and Variables with default values

ujibang avatar Feb 10 '24 09:02 ujibang

ah ok so avars containes any variable either for match or for projection?

trappa92 avatar Feb 10 '24 10:02 trappa92

Yes, with the qparam ?avars={"foo": "bar}, a stage can use it anywhere as {"$var": "foo"}.

An optional stage can use it as {"$ifvar": [ "foo", {...}].

I thought this was clearly documented. If you have suggestions on how to improve the documentation please send us any feedback.

ujibang avatar Feb 10 '24 16:02 ujibang