Forum BigDB array wont Save()

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

array wont Save()

Postby carsonmorton » July 21st, 2012, 11:11 pm

I am having odd issues adding to a database array
Code: Select all
PlayerIO.BigDB.Load("tableName", "objectKey", delegate(DatabaseObject result)
{
    result.GetArray("arrayName").Add(someItemToAdd);
    result.Save();
});

the object already has the database array with the proper name. As I have the code now, it will add one item to the array, but only one. After that I cant get it to put any more items it.

and while I'm here, I have two other questions:
is there a way to shrink a database array by shifting everything down so there are no empty spaces?
is there a way to add to the first available empty space?
carsonmorton
 
Posts: 39
Joined: April 24th, 2012, 3:12 am

Re: array wont Save()

Postby Henrik » July 22nd, 2012, 10:58 am

carsonmorton wrote:After that I cant get it to put any more items it.

What happens? What does it look like in the Admin Panel? Have you completed the save before you load it a second time? Why don't you keep a reference to the object (or array) and keep adding items to that?

carsonmorton wrote:and while I'm here, I have two other questions:
is there a way to shrink a database array by shifting everything down so there are no empty spaces?
is there a way to add to the first available empty space?

No, and no. Sorry. What are you trying to do?
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: array wont Save()

Postby carsonmorton » July 23rd, 2012, 6:48 pm

well, I figured out where the first problem was... when adding a new doodad to a level the client would send the stats to the server, the server sends them to the database, then sends the key back to the client to use later. but i found where it was changing the level key instead of the doodad key. which is why it saved the first doodad into the level, but then couldn't find the level again later.

as for why I asked the second two questions: in the database, the levelObject has a databaseArray that holds all the keys for the doodads. That way I can load a level object and then load each doodad (and get the type, x/y coordinates, etc) As I delete a doodad, it'll leave holes in the databasearray. Really it would just feel 'cleaner' if there were a simple way to avoid leaving holes.
carsonmorton
 
Posts: 39
Joined: April 24th, 2012, 3:12 am


Return to BigDB