Refactor the code for using a single MongoDB for all graphs