At least this was our story. Our two years old choice of AlfredDB was wrong. It looks promising, but as we start to work with real data-sets (>10k of records) it became nightmare. We spent months trying to fix it, but, no luck. The main problem is that buggy database engine prevent us from active development of our main application while it was a priority.
One day we decided that we can’t get such risks anymore. We decided to switch to MongoDB with goal to complete our application without worrying about bugs in database. Surprisingly migration was not easy. The fact that database uses MongoDB alike query syntax and has find and findOne methods do not means that it is easy to replace it with MongoDB. For those who saw The Pulp Fiction there are too much of little differences – “It’s the little differences. I mean, they got the same shit over there that we got here, but it’s just…it’s just, there it’s a little different”.
While one part of team work with application itself and didn’t worry about database issues another part of team was building embedded database that will be capable to transparently replace Mongodb. It was not easy but if you focus on this from beginning you can do it. First our decision was that we must have good test coverage and all tests must pass both with MongoDB and TingoDB. Looking back, this was very important decision, we was not need to invent something, we just need to reproduce existing functionality.
Once some core functionality was ready we come to idea that we can reuse tests from MongoDB Node.js driver project. It was not easy as well. We discover that original API is designed to be way too flexible. Many functions can work with or without callback. Some functions accept many different parameter combinations. We have surprised to found that find method support 7 different parameter combinations and on every its call there are dozens of code lines that just guess what you actually want to do. To be honest we was upset with that, but now we at least know how to call it to make this code run faster. Also tests verify use of many options or behaviours that we never used in real life and was not aware. No matter what we precisely duplicate all behaviours including exception error messages and even bugs (as we think about them).