Skip to content

Instantly share code, notes, and snippets.

@Lintzmaia
Created October 24, 2019 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lintzmaia/ad2b7527a5c90c6246e75f93df37f9ea to your computer and use it in GitHub Desktop.
Save Lintzmaia/ad2b7527a5c90c6246e75f93df37f9ea to your computer and use it in GitHub Desktop.
local nk = require("nakama")
local function ReadObjectEncode(context, payload)
local user_id = "removed-for-sharing-on-gist" -- some user ID.
local json = nk.json_decode(payload)
local object_ids = {
{collection = json.collection, key = json.key, user_id = user_id}
}
local objects = nk.storage_read(object_ids)
for _, r in ipairs(objects)
do
return nk.json_encode(r.value)
end
return "Wrong collection/key"
end
nk.register_rpc(ReadObjectEncode, "read_object_encode")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment