Hi all,
I am working on a problem that requires me to update some documents in the database, but I also need to get the full list of all updated documents and their data (so, not just the count or just id-s). This could be solved simply by using two different queries, but I want to avoid that if possible because performance holds a lot of weight in this particular problem.
After some digging, I saw the aggregate function and got very close to the desired behavior, but it diverged from what I need at the last step:
with the aggregation pipeline, I can match all my documents and alter the fields I need, but if I want the data to be written to the database, I need to use the $out operator.
As far as I managed to discover with my testing, if I use the $out operator, I cannot access the data in the calling program (Python 3.8, PyMongo 3.11.4). However, if I don’t use the $out operator, I can access the data in the calling program, but it won’t be written to the database.
Does someone have a suggestion about how to solve this problem efficiently? Did I approach this problem from a wrong angle entirely?
Thank you in advance.