Hello, if i have collection Persons which have name, age, position fields
I also have Houses collection, that have address, floors fields.
But House also needs to have persons list with all persons that live in that particular house.
I understand that i can save list of references persons: [ObjectId]
and than populate persons.
but i need to store person name in houses collection persons: [{ref: ObjectId, name: <referenced person name>}]
. Data can be updated eventually (asynchrony) but there needs to be guarantees that they will. Or explicitly see which parts have not updated and what why.
Maybe there is something ready.
If not, my best idea currently is as fallows: use changeStreams with cursor (so no changes have been missed out on) + each change initiates agenda job if needed to replicate data (so there are explicit success/failure for each particular “replication”).
Im not entirely happy with this solution as i think it could get slow with large amount of data. Maybe there are other caveats to such approach. Maybe if there isn’t some out of the box solution, maybe there are some other way how to approach this?
Other way was to on save, trigger save for other places as well (as agenda), but ideally things would update correctly even if changed directly in db, or from other app. Change stream would handle those cases as i understand.