Save the document in database