// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.14.0
// source: user_store_query.sql

package relation

import (
	"context"
	"database/sql"
	"time"
)

const createUserFileRelation = `-- name: CreateUserFileRelation :execresult
INSERT INTO user_file_relation (
        file_id,
        user_id,
        created_at,
        updated_at,
        deleted_at
    )
VALUES (?, ?, ?, ?, ?)
`

type CreateUserFileRelationParams struct {
	FileID    int64        `db:"file_id" json:"file_id"`
	UserID    int64        `db:"user_id" json:"user_id"`
	CreatedAt time.Time    `db:"created_at" json:"created_at"`
	UpdatedAt sql.NullTime `db:"updated_at" json:"updated_at"`
	DeletedAt sql.NullTime `db:"deleted_at" json:"deleted_at"`
}

func (q *Queries) CreateUserFileRelation(ctx context.Context, arg *CreateUserFileRelationParams) (sql.Result, error) {
	return q.exec(ctx, q.createUserFileRelationStmt, createUserFileRelation,
		arg.FileID,
		arg.UserID,
		arg.CreatedAt,
		arg.UpdatedAt,
		arg.DeletedAt,
	)
}

const deleteRelationByFileID = `-- name: DeleteRelationByFileID :exec
DELETE FROM user_file_relation
WHERE file_id = ?
`

func (q *Queries) DeleteRelationByFileID(ctx context.Context, fileID int64) error {
	_, err := q.exec(ctx, q.deleteRelationByFileIDStmt, deleteRelationByFileID, fileID)
	return err
}

const deleteRelationByUserID = `-- name: DeleteRelationByUserID :exec
DELETE FROM user_file_relation
WHERE user_id = ?
`

func (q *Queries) DeleteRelationByUserID(ctx context.Context, userID int64) error {
	_, err := q.exec(ctx, q.deleteRelationByUserIDStmt, deleteRelationByUserID, userID)
	return err
}

const getFileUserRelationByFileID = `-- name: GetFileUserRelationByFileID :one
SELECT user_id, file_id, created_at, updated_at, deleted_at
FROM user_file_relation
WHERE file_id = ?
LIMIT 1
`

func (q *Queries) GetFileUserRelationByFileID(ctx context.Context, fileID int64) (UserFileRelation, error) {
	row := q.queryRow(ctx, q.getFileUserRelationByFileIDStmt, getFileUserRelationByFileID, fileID)
	var i UserFileRelation
	err := row.Scan(
		&i.UserID,
		&i.FileID,
		&i.CreatedAt,
		&i.UpdatedAt,
		&i.DeletedAt,
	)
	return i, err
}

const getFileUserRelationByUserID = `-- name: GetFileUserRelationByUserID :one
SELECT user_id, file_id, created_at, updated_at, deleted_at
FROM user_file_relation
WHERE user_id = ?
LIMIT 1
`

func (q *Queries) GetFileUserRelationByUserID(ctx context.Context, userID int64) (UserFileRelation, error) {
	row := q.queryRow(ctx, q.getFileUserRelationByUserIDStmt, getFileUserRelationByUserID, userID)
	var i UserFileRelation
	err := row.Scan(
		&i.UserID,
		&i.FileID,
		&i.CreatedAt,
		&i.UpdatedAt,
		&i.DeletedAt,
	)
	return i, err
}
