Let us assume I have a document that looks like this:
{
“_id”: {
“$oid”: “123”
},
“stock_prices”: {
“AAPL”: {
“last_updated”: {
“$date”: “2024-09-23T11:58:58.480Z”
},
“price”: 227.3
},
“TSLA”: {
“last_updated”: {
“$date”: “2024-09-23T11:58:58.480Z”
},
“price”: 247.16
}
}
}
Now my goal is to listen to changes to the price field of any stock. I assume this is possible by specifying a regex in the pipeline. My current pipeline which consumes all changes looks like this:
pipeline = [
{
‘$match’: {
‘$or’: [
{‘updateDescription.updatedFields’:{
‘$exists’: True
}
}
]
}
}
]
How can I modify it to listen to changes in the price field of any stock? If it is not possible to listen to the changes of a generic stock, I would like to know if it is possible to listen to changes of a hardcoded stock.