Find storage object by value

Hello! I do have 3 quick questions that i would love to have answered! :slight_smile:

  1. It seems that its not possible to get a storage object by value, this is correct right?

  2. Can i, within the go framework retrieve a record linked to a specific userId as the server user? or do i need to know the userId of that record to be able to get it out of the database? I really dont want to change so that the userId is set to servers id.

  3. Is it possible, in any way, to get the match state in a rpc call? This is something that i really want. Currenly building a friend system (this is not suitable in my casehttps://heroiclabs.com/docs/nakama/concepts/friends/) and id like to know if any of the friends is online atm. Benefits of using rpc as far as i know is that you can send and wait for a response instead of getting friendlist in sending a as an action state (as you do in moving the player etc).

Best regards
/g

1: i’m not aware of a functionality for this. Imagine you want to get an image “sample.jpg” which you can do. But you can not query the “image with the most red pixels”

2: have you tried querying with an empty/nil userId? the server framework should be able to get all storage objects. (can’t confirm though)

3:
i recently build an administration site and needed to access match state. You can use matchSignal to interact with the match/state. Note that this call is processed in the matchLoop. So it’s answer time is directly related to your tickRate (if i understand this correctly. I can only talk for JS runtime, maybe go is better?)

In my case i send payload “peek” and return the current ticks and state.

const matchSignal: nkruntime.MatchSignalFunction<ServerMatchState> = (ctx, logger, nk, dispatcher, tick, state, data) => {
  if (data == 'peek')
    return {
      state,
      data: JSON.stringify({
        tick,
        state
      }),
    };

  return {
    state,
    data: ''
  }
};

If you want to see which users are actually in any match, you are probably better using matchLabels, which are far easier queryable, and probably faster then signaling all running matches.

Thank you for ur reply!

Ill try querying using an empty id. I agree that the server should be able to get a record no matter what userid its user id is set to.

I’ll look into match signals and see if its viable! Thanks!