2025-04-16 00:58:44 -04:00

114 lines
1.8 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: file.sql
package sqlc
import (
"context"
)
const deleteFile = `-- name: DeleteFile :exec
DELETE FROM file
WHERE
id = ?1
AND
user_id = ?2
`
type DeleteFileParams struct {
ID int64
UserID int64
}
func (q *Queries) DeleteFile(ctx context.Context, arg DeleteFileParams) error {
_, err := q.db.ExecContext(ctx, deleteFile, arg.ID, arg.UserID)
return err
}
const getFile = `-- name: GetFile :one
SELECT
id,
name,
data,
user_id
FROM file
WHERE
id = ?1
AND
user_id = ?2
LIMIT 1
`
type GetFileParams struct {
ID int64
UserID int64
}
func (q *Queries) GetFile(ctx context.Context, arg GetFileParams) (File, error) {
row := q.db.QueryRowContext(ctx, getFile, arg.ID, arg.UserID)
var i File
err := row.Scan(
&i.ID,
&i.Name,
&i.Data,
&i.UserID,
)
return i, err
}
const insertFile = `-- name: InsertFile :one
INSERT INTO file (
name,
data,
user_id
) VALUES (
?1,
?2,
?3
)
RETURNING id
`
type InsertFileParams struct {
Name string
Data []byte
UserID int64
}
func (q *Queries) InsertFile(ctx context.Context, arg InsertFileParams) (int64, error) {
row := q.db.QueryRowContext(ctx, insertFile, arg.Name, arg.Data, arg.UserID)
var id int64
err := row.Scan(&id)
return id, err
}
const updateFile = `-- name: UpdateFile :exec
UPDATE file
SET
name = COALESCE(?1, name),
data = COALESCE(?2, data)
WHERE
id = ?3
AND
user_id = ?4
`
type UpdateFileParams struct {
Name *string
Data []byte
ID int64
UserID int64
}
func (q *Queries) UpdateFile(ctx context.Context, arg UpdateFileParams) error {
_, err := q.db.ExecContext(ctx, updateFile,
arg.Name,
arg.Data,
arg.ID,
arg.UserID,
)
return err
}