Lua error when creating storage index

I’m trying to add an index on my collections but even the code provided in the documentation fails. When I try this code

local nk = require("nakama")

local name = "IndexName"
local collection = "CollectionName"
local key = "KeyName"
local fields = {"field1", "field2"} -- Only objects containing any of these keys and respective values are indexed.
local maxEntries = 1000

local err = nk.register_storage_index(name, collection, key, fields, maxEntries)

It fails with

{"level":"fatal","ts":"2023-10-16T17:25:06.904Z","caller":"main.go:158","msg":"Failed initializing runtime modules","error":"data/modules/test.lua:9: attempt to call a non-function object\nstack traceback:\n\tdata/modules/test.lua:9: in main chunk\n\t[G]: ?"}

Hello @anteaters,

What version of Nakama are you running? The Storage Index APIs were introduced in v3.17.0.

Best.

Oh that explains it. I’m using “3.16.0+27ba93d3” at the moment. I’ll update and see if it works. Good catch, thank you very much.

Switched to “3.17.1+c3b317d8” and it works as it should.