I am inserting it in different collections, what is wrong with that? One the document first gets removed from collection, then the updated one goes in, and the other goes into a back up collection with all the many times it restarts so a record is kept for safekeeping and development usage… I’m confused
The variables are pointing to different collections, check bellow:
var TFTDBCHECK = client.db("data").collection("TFTbc");
var TFTDBCHECKBUP = client.db("data").collection("TFTbcBUP");
Heres what I did, and as far as I’ve went I’m having no errors…
I turned the BUP one to a function, thus separating the logic processing of the insertion into two different processes, I think, at least in my head it goes like that, either that or it was a timing issue, as I see no problem in uploading the file multiple times in different collections, simply perhaps a _id issue was in the difference in milliseconds at which the insertions were being made via the Mongodb framework… whatcha recon?
If mongod complains that you have a duplicate _id then it is because your code insert it twice in the collection. There is no implicit insert done by any part of the system. If the error only occurs from time to time, then most likely the initial states of your collections is not what you think.
But the real question why to you duplicate your document in 2 collections?
Also, why in the original code, do you remove the document in only 1 collection but not in both?