Better way to update user metada?

You can omit all parameters you want to leave unchanged. As the documentation for account update says you can use nil or just leave the fields out.

local nk = require("nakama")

local user_id = "4ec4f126-3f9d-11e7-84ef-b7c182b36521" -- some user's id.
local metadata = {}

local status, err = pcall(nk.account_update_id, user_id, metadata)
if (not status) then
  nk.logger_info(("Account update error: %q"):format(err))
end

That should work and do exactly what you want. Yes, storing ELO in metadata is a good idea.

2 Likes