Adding a backend for MongoDB

It's attached. Tested and it works; fixed some bugs. Not sure if I should have :safe=>true everywhere.