func (c *Category) Update(ctx context.Context, db DB) error {
	switch {
	case !c._exists:  
		return logerror(&ErrUpdateFailed{ErrDoesNotExist})
	case c._deleted:  
		return logerror(&ErrUpdateFailed{ErrMarkedForDeletion})
	}
	const sqlstr = `UPDATE public.categories SET (` +
		`category_name, description, picture` +
		`) = ( ` +
		`$1, $2, $3` +
		`) WHERE category_id = $4`
	logf(sqlstr, c.CategoryName, c.Description, c.Picture, c.CategoryID)
	if _, err := db.ExecContext(ctx, sqlstr, c.CategoryName, c.Description, c.Picture, c.CategoryID); err != nil {
		return logerror(err)
	}
	return nil
}
Update updates a Category in the database.
package models
import (
	"context"
	"database/sql"
)
type Category struct {
	CategoryID   int16          `json:"category_id"`    
	CategoryName string         `json:"category_name"`  
	Description  sql.NullString `json:"description"`    
	Picture      []byte         `json:"picture"`        
	_exists, _deleted bool
}
func (c *Category) Exists() bool {
	return c._exists
}
func (c *Category) Deleted() bool {
	return c._deleted
}
func (c *Category) Insert(ctx context.Context, db DB) error {
	switch {
	case c._exists:  
		return logerror(&ErrInsertFailed{ErrAlreadyExists})
	case c._deleted:  
		return logerror(&ErrInsertFailed{ErrMarkedForDeletion})
	}
	const sqlstr = `INSERT INTO public.categories (` +
		`category_id, category_name, description, picture` +
		`) VALUES (` +
		`$1, $2, $3, $4` +
		`)`
	logf(sqlstr, c.CategoryID, c.CategoryName, c.Description, c.Picture)
	if _, err := db.ExecContext(ctx, sqlstr, c.CategoryID, c.CategoryName, c.Description, c.Picture); err != nil {
		return logerror(err)
	}
	c._exists = true
	return nil
}