diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-11-28 16:02:17 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-11-28 16:02:17 -0800 |
commit | 7f3d525432f65359acb6cd002440d5476eb6c76e (patch) | |
tree | d8d88da57b562fe39bc3c1d1d54e674478f9f340 /content | |
parent | 958c20bb03e8487225e300782731e512f01a0db5 (diff) |
fix for uuid implementation, was overwriting uuid on save w/ 0 value
Diffstat (limited to 'content')
-rw-r--r-- | content/item.go | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/content/item.go b/content/item.go index 4583c07..9eb3c16 100644 --- a/content/item.go +++ b/content/item.go @@ -14,12 +14,14 @@ type Sluggable interface { SetSlug(string) } -// Identifiable enables a struct to have its ID set. Typically this is done +// Identifiable enables a struct to have its ID set/get. Typically this is done // to set an ID to -1 indicating it is new for DB inserts, since by default // a newly initialized struct would have an ID of 0, the int zero-value, and // BoltDB's starting key per bucket is 0, thus overwriting the first record. type Identifiable interface { + ItemID() int SetItemID(int) + UniqueID() uuid.UUID } // Hookable provides our user with an easy way to intercept or add functionality @@ -58,21 +60,29 @@ func (i Item) Touch() int64 { return i.Updated } -// ItemID partially implements the Sortable interface -func (i Item) ItemID() int { - return i.ID -} - // SetSlug sets the item's slug for its URL func (i *Item) SetSlug(slug string) { i.Slug = slug } +// ItemID gets the Item's ID field +// partially implements the Identifiable interface +func (i Item) ItemID() int { + return i.ID +} + // SetItemID sets the Item's ID field +// partially implements the Identifiable interface func (i *Item) SetItemID(id int) { i.ID = id } +// UniqueID gets the Item's UUID field +// partially implements the Identifiable interface +func (i Item) UniqueID() uuid.UUID { + return i.UUID +} + // BeforeSave is a no-op to ensure structs which embed Item implement Hookable func (i Item) BeforeSave(req *http.Request) error { return nil |