Fixed a bug when saving a new document in model