Added query and insert function to mongodb