// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.30.0
// source: emoji.sql

package dbgen

import (
	"context"
	"database/sql"
)

const createEmoji = `-- name: CreateEmoji :one
INSERT INTO emoji (shortcode, filename, mime_type, uploaded_by)
VALUES (?, ?, ?, ?)
RETURNING id, shortcode, filename, mime_type, uploaded_by, created_at
`

type CreateEmojiParams struct {
	Shortcode  string `json:"shortcode"`
	Filename   string `json:"filename"`
	MimeType   string `json:"mimeType"`
	UploadedBy int64  `json:"uploadedBy"`
}

type CreateEmojiRow struct {
	ID         int64  `json:"id"`
	Shortcode  string `json:"shortcode"`
	Filename   string `json:"filename"`
	MimeType   string `json:"mimeType"`
	UploadedBy int64  `json:"uploadedBy"`
	CreatedAt  string `json:"createdAt"`
}

func (q *Queries) CreateEmoji(ctx context.Context, arg CreateEmojiParams) (CreateEmojiRow, error) {
	row := q.db.QueryRowContext(ctx, createEmoji,
		arg.Shortcode,
		arg.Filename,
		arg.MimeType,
		arg.UploadedBy,
	)
	var i CreateEmojiRow
	err := row.Scan(
		&i.ID,
		&i.Shortcode,
		&i.Filename,
		&i.MimeType,
		&i.UploadedBy,
		&i.CreatedAt,
	)
	return i, err
}

const deleteEmoji = `-- name: DeleteEmoji :execresult
DELETE FROM emoji WHERE id = ?
`

func (q *Queries) DeleteEmoji(ctx context.Context, id int64) (sql.Result, error) {
	return q.db.ExecContext(ctx, deleteEmoji, id)
}

const getEmojiByID = `-- name: GetEmojiByID :one
SELECT id, shortcode, filename, mime_type, uploaded_by, created_at
FROM emoji WHERE id = ?
`

type GetEmojiByIDRow struct {
	ID         int64  `json:"id"`
	Shortcode  string `json:"shortcode"`
	Filename   string `json:"filename"`
	MimeType   string `json:"mimeType"`
	UploadedBy int64  `json:"uploadedBy"`
	CreatedAt  string `json:"createdAt"`
}

func (q *Queries) GetEmojiByID(ctx context.Context, id int64) (GetEmojiByIDRow, error) {
	row := q.db.QueryRowContext(ctx, getEmojiByID, id)
	var i GetEmojiByIDRow
	err := row.Scan(
		&i.ID,
		&i.Shortcode,
		&i.Filename,
		&i.MimeType,
		&i.UploadedBy,
		&i.CreatedAt,
	)
	return i, err
}

const getEmojiByShortcode = `-- name: GetEmojiByShortcode :one
SELECT id, shortcode, filename, mime_type, uploaded_by, created_at
FROM emoji WHERE shortcode = ?
`

type GetEmojiByShortcodeRow struct {
	ID         int64  `json:"id"`
	Shortcode  string `json:"shortcode"`
	Filename   string `json:"filename"`
	MimeType   string `json:"mimeType"`
	UploadedBy int64  `json:"uploadedBy"`
	CreatedAt  string `json:"createdAt"`
}

func (q *Queries) GetEmojiByShortcode(ctx context.Context, shortcode string) (GetEmojiByShortcodeRow, error) {
	row := q.db.QueryRowContext(ctx, getEmojiByShortcode, shortcode)
	var i GetEmojiByShortcodeRow
	err := row.Scan(
		&i.ID,
		&i.Shortcode,
		&i.Filename,
		&i.MimeType,
		&i.UploadedBy,
		&i.CreatedAt,
	)
	return i, err
}

const listEmoji = `-- name: ListEmoji :many
SELECT id, shortcode, filename, mime_type, uploaded_by, created_at
FROM emoji ORDER BY shortcode ASC
`

type ListEmojiRow struct {
	ID         int64  `json:"id"`
	Shortcode  string `json:"shortcode"`
	Filename   string `json:"filename"`
	MimeType   string `json:"mimeType"`
	UploadedBy int64  `json:"uploadedBy"`
	CreatedAt  string `json:"createdAt"`
}

func (q *Queries) ListEmoji(ctx context.Context) ([]ListEmojiRow, error) {
	rows, err := q.db.QueryContext(ctx, listEmoji)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListEmojiRow{}
	for rows.Next() {
		var i ListEmojiRow
		if err := rows.Scan(
			&i.ID,
			&i.Shortcode,
			&i.Filename,
			&i.MimeType,
			&i.UploadedBy,
			&i.CreatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}
