// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.27.0
// source: query.sql

package db

import (
	"context"
	"database/sql"
)

const getGroups = `-- name: GetGroups :many
SELECT
    rg.groupId,
    rg.groupName
FROM 
    RouterGroup rg
WHERE
    rg.groupName LIKE CONCAT('%', COALESCE($1::text, rg.groupName), '%') AND
    rg.groupId = COALESCE($2, rg.groupId)
`

type GetGroupsParams struct {
	GroupName sql.NullString
	GroupId   sql.NullInt32
}

type GetGroupsRow struct {
	Groupid   int32
	Groupname string
}

func (q *Queries) GetGroups(ctx context.Context, arg GetGroupsParams) ([]GetGroupsRow, error) {
	rows, err := q.db.QueryContext(ctx, getGroups, arg.GroupName, arg.GroupId)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []GetGroupsRow
	for rows.Next() {
		var i GetGroupsRow
		if err := rows.Scan(&i.Groupid, &i.Groupname); 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
}
