Forum BigDB How does DatabaseObject detect changes?

Discussion and help relating to the PlayerIO database solution, BigDB.

How does DatabaseObject detect changes?

Postby cjcenizal » May 12th, 2011, 1:01 am

Let's say I query a table and get a DatabaseObject that looks like this:

Code: Select all
tableKey = {
   inventory: {
      0,
      1,
      2,
      3   
   }
}


Let's say in my AS3, I do this:

Code: Select all
var dbObject:DatabaseObject = /* query that returns the above object */;
dbObject.inventory = { 0, 1, 2, 3 };
dbObject.save();


I've read on the forums that DatabaseObjects only save changes. In this situation, what does it do? I have "changed" it by overwriting a property, but I've overwritten it with identical data to what was there previously. Does all of this identical data qualify as a change it will try to save?
cjcenizal
Paid Member
 
Posts: 115
Joined: March 29th, 2011, 12:31 am

Re: How does DatabaseObject detect changes?

Postby Oliver » May 17th, 2011, 12:35 pm

In AS3, changes are found by comparing the loaded object with the object being saved. This comparison is being done at save time, and since the objects in this case are identical, nothing will be sent to BigDB.

The C# client is different. It only tracks which fields are dirty, and sends all fields marked as dirty to the backend on every save.

-Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: How does DatabaseObject detect changes?

Postby cjcenizal » May 17th, 2011, 5:18 pm

That's awesome. Thanks Oliver!
cjcenizal
Paid Member
 
Posts: 115
Joined: March 29th, 2011, 12:31 am


Return to BigDB