Skip to content

Commit

Permalink
Added truncating to lastUpdated
Browse files Browse the repository at this point in the history
  • Loading branch information
mrusme committed Dec 14, 2022
1 parent b8a4e64 commit cb8d648
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions api/v1/bookmarks/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"strings"
"time"

// "github.com/google/uuid"
"github.com/go-playground/validator/v10"
Expand Down Expand Up @@ -77,6 +78,7 @@ func (h *handler) Create(ctx *fiber.Ctx) error {
dbBookmark, err := h.entClient.Bookmark.
Create().
SetBookmarks("").
SetLastUpdated(time.Now().Truncate(time.Millisecond)).
SetVersion(createBookmark.Version).
Save(context.Background())

Expand Down
4 changes: 2 additions & 2 deletions api/v1/bookmarks/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ func (h *handler) Update(ctx *fiber.Ctx) error {
})
}

now := time.Now()
now := time.Now().Truncate(time.Millisecond)
dbBookmarkN, err := h.entClient.Bookmark.
Update().
Where(bookmark.And(
bookmark.ID(id),
bookmark.LastUpdated(lastUpdated),
bookmark.LastUpdated(lastUpdated.Truncate(time.Millisecond)),
)).
SetBookmarks(updateBookmark.Bookmarks).
SetLastUpdated(now).
Expand Down

0 comments on commit cb8d648

Please sign in to comment.