Let me explain my issue which is unlikely, but possible to happen.
I have two collections, A, and B. B is "child" of A - so A has a field b_id
. I want to read A, with it's B child in a consistent state. The thing I'm worried about is this:
A (in state 0) read
B changed (from state 0 to state 1)
B (in state 1) read
What I want is:
A (in state 0) read
B changed (from state 0 to state 1)
B (in state 0) read
To help imagining, once I start the reading "process", I want to have a consistent "snapshot" of the database, so even if a change happens to B in that few milliseconds of difference between the read of A, and B, I will read the B in the state it was when I started reading.
It's pretty hard to test, so it's more like a theoretical question. I was doing research about populating, aggregation, but it feels like even those methods work sequentially, so there's a chance it will fail in the above case, but I don't know. Which method (if exist) could provide the solution for the above problem?