forked from adjoeio/djoemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.go
More file actions
32 lines (27 loc) · 638 Bytes
/
model.go
File metadata and controls
32 lines (27 loc) · 638 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package djoemo
// Model ...
type Model struct {
Version uint
CreatedAt *DjoemoTime
UpdatedAt *DjoemoTime
}
// GetVersion returns the current version of the item from dynamo
func (m *Model) GetVersion() uint {
return m.Version
}
// IncreaseVersion increases the current version by 1
func (m *Model) IncreaseVersion() {
m.Version = m.Version + 1
}
// InitCreatedAt sets the CreatedAt field of the item if it hasnt been set
func (m *Model) InitCreatedAt() {
if m.CreatedAt == nil {
now := Now()
m.CreatedAt = &now
}
}
//InitUpdatedAt sets the UpdatedAt
func (m *Model) InitUpdatedAt() {
now := Now()
m.UpdatedAt = &now
}