heroiclabs / nakama

Distributed server for social and realtime games and apps.

Home Page:https://heroiclabs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

storage_read BUG?

baidwwy opened this issue · comments

function SAVE_ITEM_INFO(user_id, data)
    local new_objects = {
        {
            collection      = "item_data",
            key             = "item_info_" .. data.itemnum,
            user_id         = user_id,
            value           = data,
            permission_read = 2 --public
        }
    }
    nk.storage_write(new_objects)
end

function LOAD_ITEM_INFO(user_id, itemnum)
    local object_ids = {
        {
            collection = "item_data",
            key        = "item_info_" .. itemnum,
            user_id    = user_id,
        }
    }

    local objects, err = nk.storage_read(object_ids)
    
    if objects[1] then
        return objects[1].value, objects[1].user_id == user_id
    end
end

LOAD_ITEM_INFO(nil, 123456)
If the user_id is nil, the result is empty.

Reference document.
https://heroiclabs.com/docs/nakama/concepts/storage/permissions/

  • Nakama: 3.20
  • Database: CCL v23.1.10 @ 2023/09/14 14:43:45 (go1.19.10)

my fault
storage_write must user_id = nil