feat: release v1.0.0
This commit is contained in:
98
internal/db/sqlc/files.sql.go
Normal file
98
internal/db/sqlc/files.sql.go
Normal file
@@ -0,0 +1,98 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: files.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const countFiles = `-- name: CountFiles :one
|
||||
SELECT COUNT(*)
|
||||
FROM files
|
||||
`
|
||||
|
||||
func (q *Queries) CountFiles(ctx context.Context) (int64, error) {
|
||||
row := q.db.QueryRow(ctx, countFiles)
|
||||
var count int64
|
||||
err := row.Scan(&count)
|
||||
return count, err
|
||||
}
|
||||
|
||||
const createFile = `-- name: CreateFile :one
|
||||
INSERT INTO files(file_name, file_path, original_name, folder_name, mime_type, file_size)
|
||||
VALUES ($1, $2, $3, $4, $5, $6) RETURNING id,file_path,file_name
|
||||
`
|
||||
|
||||
type CreateFileParams struct {
|
||||
FileName string `json:"file_name"`
|
||||
FilePath string `json:"file_path"`
|
||||
OriginalName string `json:"original_name"`
|
||||
FolderName string `json:"folder_name"`
|
||||
MimeType string `json:"mime_type"`
|
||||
FileSize int64 `json:"file_size"`
|
||||
}
|
||||
|
||||
type CreateFileRow struct {
|
||||
ID int32 `json:"id"`
|
||||
FilePath string `json:"file_path"`
|
||||
FileName string `json:"file_name"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateFile(ctx context.Context, arg CreateFileParams) (CreateFileRow, error) {
|
||||
row := q.db.QueryRow(ctx, createFile,
|
||||
arg.FileName,
|
||||
arg.FilePath,
|
||||
arg.OriginalName,
|
||||
arg.FolderName,
|
||||
arg.MimeType,
|
||||
arg.FileSize,
|
||||
)
|
||||
var i CreateFileRow
|
||||
err := row.Scan(&i.ID, &i.FilePath, &i.FileName)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getFiles = `-- name: GetFiles :many
|
||||
SELECT id, file_name, file_path, original_name, folder_name, mime_type, file_size, created_at, updated_at
|
||||
FROM files
|
||||
ORDER BY id LIMIT $1
|
||||
OFFSET $2
|
||||
`
|
||||
|
||||
type GetFilesParams struct {
|
||||
Limit int32 `json:"limit"`
|
||||
Offset int32 `json:"offset"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetFiles(ctx context.Context, arg GetFilesParams) ([]File, error) {
|
||||
rows, err := q.db.Query(ctx, getFiles, arg.Limit, arg.Offset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []File{}
|
||||
for rows.Next() {
|
||||
var i File
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.FileName,
|
||||
&i.FilePath,
|
||||
&i.OriginalName,
|
||||
&i.FolderName,
|
||||
&i.MimeType,
|
||||
&i.FileSize,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
Reference in New Issue
Block a user