Storage Read Request as Server best practice?

I am trying to write some persistent state as the server, which I want to retrieve as the server later. On Nakama server version 3.16.0+27ba93d3 using the Typescript Runtime.

I perform a successful write by doing the following:

      const writes: nkruntime.StorageWriteRequest[] = [
        {
            collection: 'myCollection',
            key: 'someKey',
            userId: undefined,
            value: {
              someVal: 'test'
            },
            permissionWrite: 0,
            permissionRead: 0
        }
      ];
      
      nk.storageWrite(writes);

Which does what you would expect and writes the relevant data to storage. However at a later time I try and retrieve it as follows:

  const reads: nkruntime.StorageReadRequest[] = [
      {
        collection: 'myCollection',
        key: 'someKey',
        userId: '00000000-0000-0000-0000-000000000000'
      }
  ];

  let results: nkruntime.StorageObject[] = nk.storageRead(reads);

The only way I am able to retrieve it is by hard coding in the system user empty GUID. Is this best practice, is there a better way for me to handle this type of request from the server?

In this instance I want the server to own the record because many players in a server may be accessing this data despite it not technically being public.

Hello @iamscottcab,

There’s this defined const that make it slightly easier.

Best