User Entity vs Global Entity Indexed ID
I'm putting in a system where Global entity data is used for data pertaining to levels. I can retrieve these and using the data, populate a level without issues. It's a great system as I can simply pass in the name of the level and retrieve the data by the Indexed ID and I don't have to worry about the Entity ID.
I was looking for the same feature for User Entity...but it seems to be lacking. I'm working on a cloud code script to retrieve the Level data from Global Entities but also retrieve the player level progress data, so I wanted to be able to just pass in the name of the level and retrieve both. It appears with User Entity however, I don't have an easy way to get say, the player's progress data for "level1".
What is the recommended way to work around this limitation? I could have over 100 levels and while I could store the data in one entity, I'd rather keep each level on it's own and just retrieve it with the Global Entity level data. Are there any plans to update the User Entity to include an indexed ID? Or is there another system I'm overlooking that offers the same features.
I did see Global Entities can be assigned to a player, but that did seem a little odd for data that I expected to be private for the user. I did think about using the type and just having "Level1", "Level2", etc be the types, but that seemed off for the use of the type.
Thank you for any assistance you can provide.
Have you looked into the Singleton API for User Entities?
I would think that that is exactly what you are looking for? http://getbraincloud.com/apidocs/apiref/#capi-entity-getsingleton
Basically the singleton API assumes that there will only be a single entity of a type (say "Level1") per user.
That should work for my needs. I wasn't sure if there would be any issues using the type to control the naming since I don't know how many of these there will be in the end or once the game goes live, how many more I will add.
Appreciate the help!
User entities are primarily indexed by profileId + entityType - so the singleton API will scale well no matter how many players you have.
That said, if your use case gets more complicated, with say hundreds of entities of a particular type per user (say maybe you are modelling user created towns, that sort of thing) - you could consider using Owned Custom Entities instead. You can define addition, custom indexes for those... keeps those lookups fast and efficient.
In addition, if you end up having >1000 Global Entities, you should definitely look at switching to Unowned Custom Entities. Same deal - you can define your own custom indexes...
Hope that helps!