Fresh returns a shallow copy of the current record model populated with its LATEST data state and everything else reset to the defaults (aka. no expand, no unknown fields and with default visibility flags).
()
| 632 | // with its LATEST data state and everything else reset to the defaults |
| 633 | // (aka. no expand, no unknown fields and with default visibility flags). |
| 634 | func (m *Record) Fresh() *Record { |
| 635 | newRecord := m.Original() |
| 636 | |
| 637 | // note: this will also load the Id field through m.GetRaw |
| 638 | var fieldName string |
| 639 | for _, field := range m.collection.Fields { |
| 640 | fieldName = field.GetName() |
| 641 | newRecord.SetRaw(fieldName, m.GetRaw(fieldName)) |
| 642 | } |
| 643 | |
| 644 | return newRecord |
| 645 | } |
| 646 | |
| 647 | // Clone returns a shallow copy of the current record model with all of |
| 648 | // its collection and unknown fields data, expand and flags copied. |