post_images.kind is image or video. A post can keep one video alongside up to four images. Reviewed-on: #21 Co-authored-by: codegirl-007 <s.raide@gmail.com>
This commit was merged in pull request #21.
This commit is contained in:
@@ -35,6 +35,7 @@ type PostImage struct {
|
||||
ObjectKey string
|
||||
PublicUrl string
|
||||
Description string
|
||||
Kind string
|
||||
Position int16
|
||||
Width int32
|
||||
Height int32
|
||||
|
||||
@@ -59,7 +59,7 @@ func (q *Queries) CreatePost(ctx context.Context, arg CreatePostParams) error {
|
||||
|
||||
const createPostImage = `-- name: CreatePostImage :exec
|
||||
INSERT INTO post_images (
|
||||
id, post_id, object_key, public_url, description, position, width, height, created_at
|
||||
id, post_id, object_key, public_url, description, kind, position, width, height, created_at
|
||||
)
|
||||
VALUES (
|
||||
$1,
|
||||
@@ -70,7 +70,8 @@ VALUES (
|
||||
$6,
|
||||
$7,
|
||||
$8,
|
||||
$9
|
||||
$9,
|
||||
$10
|
||||
)
|
||||
`
|
||||
|
||||
@@ -80,6 +81,7 @@ type CreatePostImageParams struct {
|
||||
ObjectKey string
|
||||
PublicUrl string
|
||||
Description string
|
||||
Kind string
|
||||
Position int16
|
||||
Width int32
|
||||
Height int32
|
||||
@@ -93,6 +95,7 @@ func (q *Queries) CreatePostImage(ctx context.Context, arg CreatePostImageParams
|
||||
arg.ObjectKey,
|
||||
arg.PublicUrl,
|
||||
arg.Description,
|
||||
arg.Kind,
|
||||
arg.Position,
|
||||
arg.Width,
|
||||
arg.Height,
|
||||
@@ -201,7 +204,7 @@ func (q *Queries) GetRootPostVoteSummary(ctx context.Context, arg GetRootPostVot
|
||||
|
||||
const listPostImages = `-- name: ListPostImages :many
|
||||
SELECT
|
||||
id, post_id, object_key, public_url, description, position, width, height, created_at
|
||||
id, post_id, object_key, public_url, description, kind, position, width, height, created_at
|
||||
FROM post_images
|
||||
WHERE post_id = $1
|
||||
ORDER BY position
|
||||
@@ -222,6 +225,7 @@ func (q *Queries) ListPostImages(ctx context.Context, postID string) ([]PostImag
|
||||
&i.ObjectKey,
|
||||
&i.PublicUrl,
|
||||
&i.Description,
|
||||
&i.Kind,
|
||||
&i.Position,
|
||||
&i.Width,
|
||||
&i.Height,
|
||||
@@ -327,7 +331,7 @@ WITH RECURSIVE thread AS (
|
||||
)
|
||||
SELECT
|
||||
images.id, images.post_id, images.object_key, images.public_url,
|
||||
images.description, images.position, images.width, images.height, images.created_at
|
||||
images.description, images.kind, images.position, images.width, images.height, images.created_at
|
||||
FROM post_images images
|
||||
JOIN thread ON thread.id = images.post_id
|
||||
ORDER BY images.post_id, images.position
|
||||
@@ -348,6 +352,7 @@ func (q *Queries) ListPostThreadImages(ctx context.Context, rootID string) ([]Po
|
||||
&i.ObjectKey,
|
||||
&i.PublicUrl,
|
||||
&i.Description,
|
||||
&i.Kind,
|
||||
&i.Position,
|
||||
&i.Width,
|
||||
&i.Height,
|
||||
|
||||
Reference in New Issue
Block a user