Dealing with unwanted versioning in mongoosejs
Mongodb and expressjs connected via mongoosejs is the default choice of stack for many a developers who are building applications on nodejs. I went with the mob and I have nothing to regret. Having spent a significant part of my life writing untestable jquery code, I knew I did not want to deal with it any more.I went with the new kid in the block angularjs.
Our application captures many actions happening on the browser and asynchronously posts them to the server. Once in a while, the responses from these requests do not come in chronological order. One fine day , while debugging I found that my document was being reverted to an earlier state seamlessly. This had never happened in my dev setup but damn the production beta servers. On debugging further I found that mongoose js ends a magical variable __v to my documents. Now this variable is handled magically behind the scenes.
Thank god to the network tab, I could isolate that __v was the culprit. Here is the fix that works