I’m doing some heavy computing in a child process so that it doesn’t hang up the main thread. However, I receive the following error when trying to save a document at the end of that process: VersionError: No matching document found for id “xxxxx” version 6 modifiedPaths “passages”.
After reading, I understand that this is because I am working with the same document in multiple processes and this causes the version error. I read that you can use document.update() instead of document.save() to bypass this error, but it yields another error that: MongoError: Performing an update on the path ‘_id’ would modify the immutable field ‘_id’.
There must be some way to update documents concurrently, or else how would you do things like scan media after upload without holding up the entire website.
I’ve also tried delete document.__v before saving and got the same error.