// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.28.0
// source: reception_otherdocuments.sql

package db

import (
	"context"
)

const createReceptionOtherDocument = `-- name: CreateReceptionOtherDocument :one
INSERT INTO reception_otherdocuments (           
     documentname,
     description,
     receptionform_id
 ) VALUES (
    $1,
    $2,
    $3
) 
RETURNING id, documentname, description, receptionform_id, created_at
`

type CreateReceptionOtherDocumentParams struct {
	Documentname    string `json:"documentname"`
	Description     string `json:"description"`
	ReceptionformID int32  `json:"receptionform_id"`
}

func (q *Queries) CreateReceptionOtherDocument(ctx context.Context, arg CreateReceptionOtherDocumentParams) (ReceptionOtherdocument, error) {
	row := q.db.QueryRowContext(ctx, createReceptionOtherDocument, arg.Documentname, arg.Description, arg.ReceptionformID)
	var i ReceptionOtherdocument
	err := row.Scan(
		&i.ID,
		&i.Documentname,
		&i.Description,
		&i.ReceptionformID,
		&i.CreatedAt,
	)
	return i, err
}

const deleteReceptionOtherDocument = `-- name: DeleteReceptionOtherDocument :exec
DELETE FROM reception_otherdocuments WHERE id= $1
`

func (q *Queries) DeleteReceptionOtherDocument(ctx context.Context, id int64) error {
	_, err := q.db.ExecContext(ctx, deleteReceptionOtherDocument, id)
	return err
}

const getReceptionOtherDocument = `-- name: GetReceptionOtherDocument :one
SELECT id, documentname, description, receptionform_id, created_at FROM reception_otherdocuments
WHERE id = $1
`

func (q *Queries) GetReceptionOtherDocument(ctx context.Context, id int64) (ReceptionOtherdocument, error) {
	row := q.db.QueryRowContext(ctx, getReceptionOtherDocument, id)
	var i ReceptionOtherdocument
	err := row.Scan(
		&i.ID,
		&i.Documentname,
		&i.Description,
		&i.ReceptionformID,
		&i.CreatedAt,
	)
	return i, err
}

const selectReceptionOtherDocument = `-- name: SelectReceptionOtherDocument :many
SELECT id, documentname, description, receptionform_id, created_at FROM reception_otherdocuments
WHERE receptionform_id = $1
`

func (q *Queries) SelectReceptionOtherDocument(ctx context.Context, receptionformID int32) ([]ReceptionOtherdocument, error) {
	rows, err := q.db.QueryContext(ctx, selectReceptionOtherDocument, receptionformID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ReceptionOtherdocument{}
	for rows.Next() {
		var i ReceptionOtherdocument
		if err := rows.Scan(
			&i.ID,
			&i.Documentname,
			&i.Description,
			&i.ReceptionformID,
			&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
}
