diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 10:47:22 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 10:47:22 -0600 |
commit | 2c4b617ddeb71a5856075c94dcc7dfff3cfcbcaa (patch) | |
tree | 66ea2c37d91e51c7b426d13db0203e5851c66bfc /srv/src/post | |
parent | 75044eef0331bb9448da813288aafc6735ce7c22 (diff) |
Implement saving of new and edited posts
Diffstat (limited to 'srv/src/post')
-rw-r--r-- | srv/src/post/post.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/srv/src/post/post.go b/srv/src/post/post.go index 766a543..803356e 100644 --- a/srv/src/post/post.go +++ b/srv/src/post/post.go @@ -124,6 +124,11 @@ func (s *store) withTx(cb func(*sql.Tx) error) error { } func (s *store) Set(post Post, now time.Time) error { + + if post.ID == "" { + return errors.New("post ID can't be empty") + } + return s.withTx(func(tx *sql.Tx) error { nowTS := now.Unix() |