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

package querytest

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
)

const getActionCodeByResource = `-- name: GetActionCodeByResource :one
SELECT code, arr.item_object ->> 'code'  as resource_code
FROM sys_actions,
    jsonb_array_elements(resources) with ordinality arr(item_object, resource)
    WHERE item_object->>'resource' = $1
    LIMIT 1
`

type GetActionCodeByResourceRow struct {
	Code         string
	ResourceCode pgtype.Text
}

func (q *Queries) GetActionCodeByResource(ctx context.Context, resource pgtype.Text) (GetActionCodeByResourceRow, error) {
	row := q.db.QueryRow(ctx, getActionCodeByResource, resource)
	var i GetActionCodeByResourceRow
	err := row.Scan(&i.Code, &i.ResourceCode)
	return i, err
}
