-- GetAllItems finds all items.
-- name: GetAllItems :many
SELECT
    id,
    itemType,
    iconURL,
    itemName,
    minItemPower,
    maxItemPower,
    rarity,
    origin,
    tooltip,
    isEventItem
FROM
    powerItem;

-- FindByID finds items by the ID
-- name: FindByID :one
SELECT
    id,
    itemType,
    iconURL,
    itemName,
    minItemPower,
    maxItemPower,
    rarity,
    origin,
    tooltip,
    isEventItem
FROM
    powerItem
WHERE
    id = pggen.arg('id');

-- AddNewItem inserts a new power item
-- name: AddNewItem :one
INSERT INTO
    powerItem (
        itemType,
        iconURL,
        itemName,
        minItemPower,
        maxItemPower,
        rarity,
        origin,
        tooltip,
        isEventItem
    )
VALUES
    (
        pggen.arg('itemType'), 
        pggen.arg('iconUrl'),
        pggen.arg('itemName'),
        pggen.arg('minItemPower'),
        pggen.arg('maxItemPower'),
        pggen.arg('rarity'),
        pggen.arg('origin'),
        pggen.arg('tooltip'),
        pggen.arg('isEventItem')
    ) RETURNING *;

-- AddNewItemWithID inserts a new power item
-- name: AddNewItemWithID :one
INSERT INTO
    powerItem (
        id,
        itemType,
        iconURL,
        itemName,
        minItemPower,
        maxItemPower,
        rarity,
        origin,
        tooltip,
        isEventItem
    )
VALUES
    (
        pggen.arg('id'),
        pggen.arg('itemType'), 
        pggen.arg('iconUrl'),
        pggen.arg('itemName'),
        pggen.arg('minItemPower'),
        pggen.arg('maxItemPower'),
        pggen.arg('rarity'),
        pggen.arg('origin'),
        pggen.arg('tooltip'),
        pggen.arg('isEventItem')
    ) RETURNING *;
