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

package db

import (
	"context"
)

const createProductDocumentType = `-- name: CreateProductDocumentType :one
INSERT INTO productdoctypes (
    pddocumentcode,
    pddocumentdescription
 ) VALUES (
    $1, $2
 ) RETURNING id, pddocumentcode, pddocumentdescription, created_at
`

type CreateProductDocumentTypeParams struct {
	Pddocumentcode        string `json:"pddocumentcode"`
	Pddocumentdescription string `json:"pddocumentdescription"`
}

func (q *Queries) CreateProductDocumentType(ctx context.Context, arg CreateProductDocumentTypeParams) (Productdoctype, error) {
	row := q.db.QueryRowContext(ctx, createProductDocumentType, arg.Pddocumentcode, arg.Pddocumentdescription)
	var i Productdoctype
	err := row.Scan(
		&i.ID,
		&i.Pddocumentcode,
		&i.Pddocumentdescription,
		&i.CreatedAt,
	)
	return i, err
}

const deleteProductDocumentType = `-- name: DeleteProductDocumentType :exec
DELETE FROM productdoctypes WHERE id= $1
`

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

const getProductDocumentType = `-- name: GetProductDocumentType :one
SELECT id, pddocumentcode, pddocumentdescription, created_at FROM productdoctypes
WHERE id = $1 LIMIT 1
`

func (q *Queries) GetProductDocumentType(ctx context.Context, id int64) (Productdoctype, error) {
	row := q.db.QueryRowContext(ctx, getProductDocumentType, id)
	var i Productdoctype
	err := row.Scan(
		&i.ID,
		&i.Pddocumentcode,
		&i.Pddocumentdescription,
		&i.CreatedAt,
	)
	return i, err
}

const listProductDocumentTypes = `-- name: ListProductDocumentTypes :many
SELECT id, pddocumentcode, pddocumentdescription, created_at FROM productdoctypes
ORDER BY id LIMIT $1
OFFSET $2
`

type ListProductDocumentTypesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

func (q *Queries) ListProductDocumentTypes(ctx context.Context, arg ListProductDocumentTypesParams) ([]Productdoctype, error) {
	rows, err := q.db.QueryContext(ctx, listProductDocumentTypes, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Productdoctype{}
	for rows.Next() {
		var i Productdoctype
		if err := rows.Scan(
			&i.ID,
			&i.Pddocumentcode,
			&i.Pddocumentdescription,
			&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
}

const updateProductDocumentType = `-- name: UpdateProductDocumentType :one
UPDATE productdoctypes
  set 
    pddocumentcode = $2,
    pddocumentdescription = $3
WHERE id = $1
RETURNING id, pddocumentcode, pddocumentdescription, created_at
`

type UpdateProductDocumentTypeParams struct {
	ID                    int64  `json:"id"`
	Pddocumentcode        string `json:"pddocumentcode"`
	Pddocumentdescription string `json:"pddocumentdescription"`
}

func (q *Queries) UpdateProductDocumentType(ctx context.Context, arg UpdateProductDocumentTypeParams) (Productdoctype, error) {
	row := q.db.QueryRowContext(ctx, updateProductDocumentType, arg.ID, arg.Pddocumentcode, arg.Pddocumentdescription)
	var i Productdoctype
	err := row.Scan(
		&i.ID,
		&i.Pddocumentcode,
		&i.Pddocumentdescription,
		&i.CreatedAt,
	)
	return i, err
}
