Move mongodb functionalities to its own library