Skip to content

Instantly share code, notes, and snippets.

@Shogan
Last active August 29, 2015 14:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Shogan/853ee54b3ec0a405ef0e to your computer and use it in GitHub Desktop.
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