FetchAllCharactersFromAWS
private void FetchAllCharactersFromAWS() | |
{ | |
resultText.text = "\n***LoadTable***"; | |
Table.LoadTableAsync(_client, "CharacterCreator", (loadTableResult) => | |
{ | |
if (loadTableResult.Exception != null) | |
{ | |
resultText.text += "\n failed to load characters table"; | |
} | |
else | |
{ | |
try | |
{ | |
var context = Context; | |
// Note scan is pretty slow for large datasets compared to a query, as we are not searching on the index. | |
var search = context.ScanAsync<CharacterEntity>(new ScanCondition("Age", ScanOperator.GreaterThan, 0)); | |
search.GetRemainingAsync(result => | |
{ | |
if (result.Exception == null) | |
{ | |
characterEntities = result.Result; | |
// Load the first character into the character display | |
if (characterEntities.Count > 0) LoadCharacter(characterEntities.First()); | |
} | |
else | |
{ | |
Debug.LogError("Failed to get async table scan results: " + result.Exception.Message); | |
} | |
}, null); | |
} | |
catch (AmazonDynamoDBException exception) | |
{ | |
Debug.Log(string.Concat("Exception fetching characters from table: {0}", exception.Message)); | |
Debug.Log(string.Concat("Error code: {0}, error type: {1}", exception.ErrorCode, exception.ErrorType)); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment