Implementation of saving idocument* to database.