Started a repository of the uploads
This commit is contained in:
parent
6b697e008f
commit
0a9af9cde8
11 changed files with 101 additions and 15 deletions
|
|
@ -55,6 +55,7 @@ type Upload struct {
|
|||
Guid string
|
||||
MimeType string
|
||||
Filename string
|
||||
FileSize int64
|
||||
Alt string
|
||||
CreatedAt int64
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,15 @@ import (
|
|||
"context"
|
||||
)
|
||||
|
||||
const deletePendingUpload = `-- name: DeletePendingUpload :exec
|
||||
DELETE FROM pending_uploads WHERE guid = ?
|
||||
`
|
||||
|
||||
func (q *Queries) DeletePendingUpload(ctx context.Context, guid string) error {
|
||||
_, err := q.db.ExecContext(ctx, deletePendingUpload, guid)
|
||||
return err
|
||||
}
|
||||
|
||||
const insertPendingUpload = `-- name: InsertPendingUpload :one
|
||||
INSERT INTO pending_uploads (
|
||||
site_id,
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func (q *Queries) InsertUpload(ctx context.Context, arg InsertUploadParams) erro
|
|||
}
|
||||
|
||||
const selectUploadByID = `-- name: SelectUploadByID :one
|
||||
SELECT id, site_id, guid, mime_type, filename, alt, created_at FROM uploads WHERE id = ?
|
||||
SELECT id, site_id, guid, mime_type, filename, file_size, alt, created_at FROM uploads WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) SelectUploadByID(ctx context.Context, id interface{}) (Upload, error) {
|
||||
|
|
@ -64,6 +64,7 @@ func (q *Queries) SelectUploadByID(ctx context.Context, id interface{}) (Upload,
|
|||
&i.Guid,
|
||||
&i.MimeType,
|
||||
&i.Filename,
|
||||
&i.FileSize,
|
||||
&i.Alt,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
|
|
@ -71,7 +72,7 @@ func (q *Queries) SelectUploadByID(ctx context.Context, id interface{}) (Upload,
|
|||
}
|
||||
|
||||
const selectUploadsOfSite = `-- name: SelectUploadsOfSite :many
|
||||
SELECT id, site_id, guid, mime_type, filename, alt, created_at FROM uploads WHERE site_id = ? ORDER BY created_at DESC
|
||||
SELECT id, site_id, guid, mime_type, filename, file_size, alt, created_at FROM uploads WHERE site_id = ? ORDER BY created_at DESC
|
||||
`
|
||||
|
||||
func (q *Queries) SelectUploadsOfSite(ctx context.Context, siteID int64) ([]Upload, error) {
|
||||
|
|
@ -89,6 +90,7 @@ func (q *Queries) SelectUploadsOfSite(ctx context.Context, siteID int64) ([]Uplo
|
|||
&i.Guid,
|
||||
&i.MimeType,
|
||||
&i.Filename,
|
||||
&i.FileSize,
|
||||
&i.Alt,
|
||||
&i.CreatedAt,
|
||||
); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue