#9 - feed follows

This commit is contained in:
2025-03-11 14:53:10 +02:00
parent ed8b8860b7
commit b7b7a7d55d
12 changed files with 324 additions and 1 deletions

View File

@@ -0,0 +1,73 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: createFeedFollow.sql
package database
import (
"context"
"time"
"github.com/google/uuid"
)
const createFeedFollow = `-- name: CreateFeedFollow :one
WITH inserted_feed_follow AS (
INSERT INTO feed_follows (id, created_at, updated_at, user_id, feed_id)
VALUES (
$1,
$2,
$3,
$4,
$5
)
RETURNING id, created_at, updated_at, user_id, feed_id
) SELECT
inserted_feed_follow.id, inserted_feed_follow.created_at, inserted_feed_follow.updated_at, inserted_feed_follow.user_id, inserted_feed_follow.feed_id,
feeds.name AS feed_name,
users.name AS user_name
FROM inserted_feed_follow
INNER JOIN users ON users.id = inserted_feed_follow.user_id
INNER JOIN feeds ON feeds.id = inserted_feed_follow.feed_id
`
type CreateFeedFollowParams struct {
ID uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
UserID uuid.UUID
FeedID uuid.UUID
}
type CreateFeedFollowRow struct {
ID uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
UserID uuid.UUID
FeedID uuid.UUID
FeedName string
UserName string
}
func (q *Queries) CreateFeedFollow(ctx context.Context, arg CreateFeedFollowParams) (CreateFeedFollowRow, error) {
row := q.db.QueryRowContext(ctx, createFeedFollow,
arg.ID,
arg.CreatedAt,
arg.UpdatedAt,
arg.UserID,
arg.FeedID,
)
var i CreateFeedFollowRow
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.UserID,
&i.FeedID,
&i.FeedName,
&i.UserName,
)
return i, err
}