From 2c4b617ddeb71a5856075c94dcc7dfff3cfcbcaa Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 20 May 2022 10:47:22 -0600 Subject: Implement saving of new and edited posts --- srv/src/post/post.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'srv/src/post/post.go') 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() -- cgit v1.2.3