write data to mongodb