/
model.go
23 lines (20 loc) · 905 Bytes
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package sql
import "time"
// Model implements the repository.Model interface for SQL backends.
// It provides a set of common generic fields and operations that partially implement the repository.Model interface.
// To use it, embed it in your application-specific repository.Model implementation.
type Model struct {
// ID contains the primary key identifier.
ID uint `gorm:"primaryKey"`
// CreatedAt contains the date and time at which this model has been persisted.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt contains the last date and time when this model has been updated.
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is used to implement soft record deletion. If set, the record will be considered
// as deleted.
DeletedAt *time.Time `json:"deleted_at" gorm:"index"`
}
// GetID returns the unique identifier for this Model.
func (m Model) GetID() uint {
return m.ID
}