Leaderboard but for clans?

i need leaderboard for clans in nakama? is there any best practices?

i know there are many ways to do it but just simply instead of saveLeaderboardScore with userId saving it with clan id can make the leaderbord but i think its not possible.
in general a group score is sum of its users scores.
is there any best practice for it?

If you use the authoritative leaderboard API then I think you can make the score’s owner ID anything you want. The docs also specifically mention this:

All records belong to an owner. This is usually a user but other objects like a group ID or some other custom ID can be used

I imagine it’s more efficient for each group member to score to a single group ID than to query every member of every group and tabulate the sum of their scores, but I can’t say for certain. I also don’t know how concurrent writes are handled if many players in a group score at the same time, but that’s the sort of thing I think Nakama handles well.

1 Like

Hello @virtouso,

@od-jg is correct, if there’s no need to keep the individual scores around, then the best way to handle it is to set up a leaderboard with incr operator, any submitted score with the guild ID will be added to the existing score. The increment is handled in the db so concurrent updates are safe.

Best.

1 Like