Forum BigDB Add new data to an existing PlayerObjects

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

Add new data to an existing PlayerObjects

Postby Testlol » April 18th, 2016, 8:58 pm

Hey,

I'm testing some things on BIGDB, but can't find the way to add a new value to an existing objects.
I found this topic : https://gamesnet.yahoo.net/forum/viewtopic.php?f=32&t=35764&p=48721&hilit=add&sid=2390cdbba527d190d931b13bedfdcfc5&sid=2390cdbba527d190d931b13bedfdcfc5#p48729 that describe what i want to do.

I have a PlayerObject containing some infos.
And i want to add Data.Player.AccountCreation to each objects on load/creation.
Seems to work well on creation cause the objects don't already exist but when it does i have this error:

Property does not exist: Data.Player.AccountCreation

This is the code for the SavePlayerObject function.
Code: Select all
            try { dbo.Set("Data.Player.AccountCreation", dbo.GetDateTime("Data.Player.AccountCreation")); }
            catch (Exception) { dbo.Set("Data.Player.AccountCreation", DateTime.UtcNow); };


Thanks for your time.
Testlol
 
Posts: 4
Joined: April 10th, 2016, 12:05 am

Re: Add new data to an existing PlayerObjects

Postby Testlol » April 18th, 2016, 9:15 pm

Found a way using Save method with overwrite set to true
Testlol
 
Posts: 4
Joined: April 10th, 2016, 12:05 am

Re: Add new data to an existing PlayerObjects

Postby Henrik » April 20th, 2016, 1:38 am

I don't quite understand what you are trying to do?

Code: Select all
dbo.Set("Data.Player.AccountCreation", dbo.GetDateTime("Data.Player.AccountCreation"))

This line does nothing if the property exists, and throws an error if it doesn't, and neither of those outcomes are what you want, right?

A better way would be to use the Contains method (https://gamesnet.yahoo.net/documentatio ... t#Contains), and then the code would look something like this:

Code: Select all
if (!dbo.Contains("Data.Player.AccountCreation")) {
    dbo.Set("Data.Player.AccountCreation", DateTime.UtcNow);
}

Calling Save() with the overwrite parameter set to true is not something you should normally need, so why exactly did you need to use that?
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Add new data to an existing PlayerObjects

Postby Testlol » April 20th, 2016, 5:51 pm

Basicly the game already have a player base, so if i want to add a new data on the existings player object, i'd have to use the overwrite of the Save method no?

Is there a better way to do it?
Testlol
 
Posts: 4
Joined: April 10th, 2016, 12:05 am

Re: Add new data to an existing PlayerObjects

Postby Henrik » April 20th, 2016, 6:14 pm

When you call Save() on an object, any changes to the object compared to what it looked like when you loaded it (or last saved it) will get sent to the server, and the object will be updated. This saves bandwidth, because it only sends over changes, not the entire object every time you save. And if you haven't made any modifications to the object, Save() doesn't send any data at all.

The overwrite parameter should only be used if you know you are modifying the object concurrently in different places, and you know that this exact version of the object that you have should be saved, so you overwrite the entire object in storage with what you have. This sends the entire object over the network, which is usually wasteful, so you should only do it if you know you need it.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Add new data to an existing PlayerObjects

Postby Testlol » April 21st, 2016, 6:17 am

Hmm ok i'll try that again Thanks!
Testlol
 
Posts: 4
Joined: April 10th, 2016, 12:05 am


Return to BigDB



cron