Store history in MongoDB