- Code: Select all
public void processCommands()
{
PlayerIO.BigDB.Load("MyObject", ConnectUserId, delegate (DatabaseObject result){
if (result != null) {
//Change a property and save back.
DatabaseObject newObj = new DatabaseObject()
newObj.Set("Property1", "Value1");
newObj.Set("Property2", "Value2");
result.Set("ComplexObject", newObj);
result.Save(null);
PlayerIO.BigDB.Load("MyObject", ConnectUserId, delegate (DatabaseObject result2){
if (result2 != null) {
//Check a property and save back.
DatabseObject oldObj = result2.GetDatabaseObject("ComplexObject");
if(oldObj !=null)
{
string value1 = oldObj.GetString("Property1");
string value2 = oldObj.GetString("Property2");
}
//Do Some Work Here Not Regarding The ComplexObject
result2.Save(null);
}
});
}
});
}
My Question is then: Is it possible for my second load call (Which happens as soon as the previous save is kicked off - but it is not a callback) to get the database object mid-save? The behavior I am seeing is that when I add a child databaseObject, some of its properties will go missing. In the code above, the ComplexObject may exist, and Property1 may have its value, but property2 would be completely missing. And I am worrying then, that calling save again (without using an optimistic lock) would lock that property2 as missing permanently.
Is that possible? Or does the Save() method block load() commands during its write process?