45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
// source: favorites_queries.sql
|
|
|
|
package db_repo
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createFavorite = `-- name: CreateFavorite :one
|
|
INSERT INTO public.favorites
|
|
(user_id, blog_id, favorited_at)
|
|
VALUES($1, $2, CURRENT_TIMESTAMP)
|
|
RETURNING user_id, blog_id, favorited_at
|
|
`
|
|
|
|
type CreateFavoriteParams struct {
|
|
UserID int64 `json:"user_id"`
|
|
BlogID int64 `json:"blog_id"`
|
|
}
|
|
|
|
func (q *Queries) CreateFavorite(ctx context.Context, arg CreateFavoriteParams) (Favorite, error) {
|
|
row := q.db.QueryRow(ctx, createFavorite, arg.UserID, arg.BlogID)
|
|
var i Favorite
|
|
err := row.Scan(&i.UserID, &i.BlogID, &i.FavoritedAt)
|
|
return i, err
|
|
}
|
|
|
|
const deleteFavorite = `-- name: DeleteFavorite :exec
|
|
DELETE FROM public.favorites
|
|
WHERE user_id=$1 AND blog_id=$2
|
|
`
|
|
|
|
type DeleteFavoriteParams struct {
|
|
UserID int64 `json:"user_id"`
|
|
BlogID int64 `json:"blog_id"`
|
|
}
|
|
|
|
func (q *Queries) DeleteFavorite(ctx context.Context, arg DeleteFavoriteParams) error {
|
|
_, err := q.db.Exec(ctx, deleteFavorite, arg.UserID, arg.BlogID)
|
|
return err
|
|
}
|