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

package db

import (
	"context"
)

const createModeOfTransport = `-- name: CreateModeOfTransport :one
INSERT INTO modesoftransport (
    topackhouse,
    toexit,
    todestination,
    motdescription
 ) VALUES (
    $1, $2, $3, $4
 ) RETURNING id, topackhouse, toexit, todestination, motdescription, status, created_at
`

type CreateModeOfTransportParams struct {
	Topackhouse    bool   `json:"topackhouse"`
	Toexit         bool   `json:"toexit"`
	Todestination  bool   `json:"todestination"`
	Motdescription string `json:"motdescription"`
}

func (q *Queries) CreateModeOfTransport(ctx context.Context, arg CreateModeOfTransportParams) (Modesoftransport, error) {
	row := q.db.QueryRowContext(ctx, createModeOfTransport,
		arg.Topackhouse,
		arg.Toexit,
		arg.Todestination,
		arg.Motdescription,
	)
	var i Modesoftransport
	err := row.Scan(
		&i.ID,
		&i.Topackhouse,
		&i.Toexit,
		&i.Todestination,
		&i.Motdescription,
		&i.Status,
		&i.CreatedAt,
	)
	return i, err
}

const deleteModeOfTransport = `-- name: DeleteModeOfTransport :exec
DELETE FROM modesoftransport WHERE id= $1
`

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

const getModeOfTransport = `-- name: GetModeOfTransport :one
SELECT id, topackhouse, toexit, todestination, motdescription, status, created_at FROM modesoftransport
WHERE id = $1 LIMIT 1
`

func (q *Queries) GetModeOfTransport(ctx context.Context, id int64) (Modesoftransport, error) {
	row := q.db.QueryRowContext(ctx, getModeOfTransport, id)
	var i Modesoftransport
	err := row.Scan(
		&i.ID,
		&i.Topackhouse,
		&i.Toexit,
		&i.Todestination,
		&i.Motdescription,
		&i.Status,
		&i.CreatedAt,
	)
	return i, err
}

const getModeofTransportIDByName = `-- name: GetModeofTransportIDByName :one
SELECT id FROM modesoftransport where motdescription= $1
`

func (q *Queries) GetModeofTransportIDByName(ctx context.Context, motdescription string) (int64, error) {
	row := q.db.QueryRowContext(ctx, getModeofTransportIDByName, motdescription)
	var id int64
	err := row.Scan(&id)
	return id, err
}

const insertBulkModesOfTransport = `-- name: InsertBulkModesOfTransport :one
INSERT INTO modesoftransport (
    topackhouse,
    toexit,
    todestination,
    motdescription
) VALUES(
   $1,
   $2,
   $3,
   $4
)
RETURNING id, topackhouse, toexit, todestination, motdescription, status, created_at
`

type InsertBulkModesOfTransportParams struct {
	Topackhouse    bool   `json:"topackhouse"`
	Toexit         bool   `json:"toexit"`
	Todestination  bool   `json:"todestination"`
	Motdescription string `json:"motdescription"`
}

func (q *Queries) InsertBulkModesOfTransport(ctx context.Context, arg InsertBulkModesOfTransportParams) (Modesoftransport, error) {
	row := q.db.QueryRowContext(ctx, insertBulkModesOfTransport,
		arg.Topackhouse,
		arg.Toexit,
		arg.Todestination,
		arg.Motdescription,
	)
	var i Modesoftransport
	err := row.Scan(
		&i.ID,
		&i.Topackhouse,
		&i.Toexit,
		&i.Todestination,
		&i.Motdescription,
		&i.Status,
		&i.CreatedAt,
	)
	return i, err
}

const listModes = `-- name: ListModes :many
SELECT id, topackhouse, toexit, todestination, motdescription, status, created_at FROM modesoftransport
`

func (q *Queries) ListModes(ctx context.Context) ([]Modesoftransport, error) {
	rows, err := q.db.QueryContext(ctx, listModes)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Modesoftransport{}
	for rows.Next() {
		var i Modesoftransport
		if err := rows.Scan(
			&i.ID,
			&i.Topackhouse,
			&i.Toexit,
			&i.Todestination,
			&i.Motdescription,
			&i.Status,
			&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 listModesOfTransport = `-- name: ListModesOfTransport :many
SELECT id, topackhouse, toexit, todestination, motdescription, status, created_at FROM modesoftransport
ORDER BY id LIMIT $1
OFFSET $2
`

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

func (q *Queries) ListModesOfTransport(ctx context.Context, arg ListModesOfTransportParams) ([]Modesoftransport, error) {
	rows, err := q.db.QueryContext(ctx, listModesOfTransport, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Modesoftransport{}
	for rows.Next() {
		var i Modesoftransport
		if err := rows.Scan(
			&i.ID,
			&i.Topackhouse,
			&i.Toexit,
			&i.Todestination,
			&i.Motdescription,
			&i.Status,
			&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 updateModeOfTransport = `-- name: UpdateModeOfTransport :one
UPDATE modesoftransport
  set 
    topackhouse = $2,
    toexit = $3,
    todestination = $4,
    motdescription = $5
WHERE id = $1
RETURNING id, topackhouse, toexit, todestination, motdescription, status, created_at
`

type UpdateModeOfTransportParams struct {
	ID             int64  `json:"id"`
	Topackhouse    bool   `json:"topackhouse"`
	Toexit         bool   `json:"toexit"`
	Todestination  bool   `json:"todestination"`
	Motdescription string `json:"motdescription"`
}

func (q *Queries) UpdateModeOfTransport(ctx context.Context, arg UpdateModeOfTransportParams) (Modesoftransport, error) {
	row := q.db.QueryRowContext(ctx, updateModeOfTransport,
		arg.ID,
		arg.Topackhouse,
		arg.Toexit,
		arg.Todestination,
		arg.Motdescription,
	)
	var i Modesoftransport
	err := row.Scan(
		&i.ID,
		&i.Topackhouse,
		&i.Toexit,
		&i.Todestination,
		&i.Motdescription,
		&i.Status,
		&i.CreatedAt,
	)
	return i, err
}
