I’m new to Nakama, and I’m really impressed with it so far.
I’m having a problem with a server side RPC written in Lua.
I try to write some data to the object storage, it works fine if I use a pcall(nk.storage_write, { obj }), but if I try nk.storage_write(obj) as it shows in the docs the object doesn’t get written to the database.
The same happens when trying to read with storage_read. I’ve included some code snippets below.
local object = {
collection = "player",
key = "data",
user_id = user_id
}
local objects = nk.storage_read(object)
local object = {
collection = "player",
key = "data",
user_id = user_id
}
local success, objects = pcall(nk.storage_read, { object })
The pcall returns the object correctly, the nk.storage_read() returns nothing.
Both functions, storage_write and storage_read, were written to accept lua tables so I believe it’s an inconsistency in the documentation. Could share the links to the snippets you based your code on?
That code works. I’m new to Lua, so I’m not sure if that is something that is obvious in the documentation or if it could be a bit clearer? The examples in the documentation all involve reading and writing passing in multiple objects as the parameter. Maybe an example passing in a single object would be beneficial?