connect to mongodb and save data