[ChangeStream]
trappa92 opened this issue · 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
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
ah ok so avars containes any variable either for match or for projection?
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.