Write data to mongodb