Sign In Register

How can we help you today?

Start a new topic
Answered

Player collection and unique Display Name

I'm trying to figure out if I should simply use a different runtime collection - or if the current System Player collection can be used the way I want.

So there is already a player DIsplayName in the Player Collection.  It is can be set upon device authentication (one of the fields is Display Name)

It can also be updated via ChangeUserDetails.


I'd like to ensure it's value is unique.


In order to do that, I'd have to add a unique index on it and/or pre-emptively do a 'find' on the display name to ensure it wasn't already in use before either of those requests (device authentication or ChangeUserDetails).   I don't see that I can add an index on System tables (like player) - so that appears to be a non-starter....


So I guess I want to create my own displayname field in some other runtime collection that I have control over - keerect?


thanks in advance!!





Best Answer

Hi Jeff,


I answered a similar question on this recently, you might find it useful, you can read it here. Basically the example code will check a displayName collection in the RegistrationRequest and will throw an error if the supplied displayName already exists, this will force the user to have to create a unique one for the Request to go through. When a unique displayName is supplied, it is added to the collection of displayNames and the new player is created. Hope this helps.


Thanks,

Liam


Answer

Hi Jeff,


I answered a similar question on this recently, you might find it useful, you can read it here. Basically the example code will check a displayName collection in the RegistrationRequest and will throw an error if the supplied displayName already exists, this will force the user to have to create a unique one for the Request to go through. When a unique displayName is supplied, it is added to the collection of displayNames and the new player is created. Hope this helps.


Thanks,

Liam

I saw that thread - is there a reason you didn't use the DisplayName in the Player collection?

Hi Jeff,


The Player system collection is purposefully not indexed as it is system critical, that's why a runtime collection was suggested in the post, you could then index the displayName field in that collection to speed up the process in the future. To use the system collection you could go with the suggestion of matching the displayName to the userName on registration, that way you'll get the system "userName taken" error if it already exists.


Thanks,

Liam

Login to post a comment