// Update updates a post by id.
Update updates a post by id.
// Update updates a post by id .
func (pr *PostRepository) Update(ctx context.Context, id uint, p post.Post) error {
	q := `
	UPDATE posts set body=$1, updated_at=$2
		WHERE id=$3;
	`
	stmt, err := pr.Data.DB.PrepareContext(ctx, q)
	if err != nil {
		return err
	}
	defer stmt.Close()
	_, err = stmt.ExecContext(
		ctx, p.Body, time.Now(), id,
	)
	if err != nil {
		return err
	}
	return nil
}
func ( pr * PostRepository ) Update ( ctx context . Context , id uint , p post . Post ) error { q := `
	UPDATE posts set body=$1, updated_at=$2
		WHERE id=$3;
	` stmt , err := pr . Data . DB . PrepareContext ( ctx , q ) if err != nil { return err } defer stmt . Close ( ) _ , err = stmt . ExecContext ( ctx , p . Body , time . Now ( ) , id , ) if err != nil { return err } return nil }
Update updates a post by id.
Update updates a post by id .