wait until mongo is connected before saving documents