------------------------------------------------------------------- NewRecord initializes a new empty Record model.
(collection *Collection)
| 537 | |
| 538 | // NewRecord initializes a new empty Record model. |
| 539 | func NewRecord(collection *Collection) *Record { |
| 540 | record := &Record{ |
| 541 | collection: collection, |
| 542 | data: store.New[string, any](nil), |
| 543 | customVisibility: store.New[string, bool](nil), |
| 544 | originalData: make(map[string]any, len(collection.Fields)), |
| 545 | } |
| 546 | |
| 547 | // initialize default field values |
| 548 | var fieldName string |
| 549 | for _, field := range collection.Fields { |
| 550 | fieldName = field.GetName() |
| 551 | |
| 552 | if fieldName == FieldNameId { |
| 553 | continue |
| 554 | } |
| 555 | |
| 556 | value, _ := field.PrepareValue(record, nil) |
| 557 | record.originalData[fieldName] = value |
| 558 | } |
| 559 | |
| 560 | return record |
| 561 | } |
| 562 | |
| 563 | // Collection returns the Collection model associated with the current Record model. |
| 564 | // |
searching dependent graphs…