|
|
|
Loading custom game data from the document database is not much harder than saving it. The hardest part has been creating the indexes to retrieve documents. These indexes can be thought as stored procedures. One really nice thing about RavenDb is that it lets you check if these indexes are there, if not, then create them. Here's the code for the index that I'm currently using:
/// <summary>
/// Creates the needed indexes, if they don't exist.
/// </summary>
public static void CreateIndexes()
{
var store = Instance;
store.DatabaseCommands.PutIndex(
"GetPlayerByDatabaseId",
new IndexDefinitionBuilder<PlayerDocument>
{
Map = docs => from doc in docs
select new
{
doc.DatabaseId
}
});
}
That DatabaseId is to match the document being saved to the player's settings in the database. It keeps things tidy.
Previous Page | Next Page
Only registered users may post comments.