Forum BigDB LoadMyPlayerObject Confusion

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

LoadMyPlayerObject Confusion

Postby getAcross » May 1st, 2011, 9:42 pm

Hi, I am currently attempting to utilize the loadMyPlayerObject function to fetch a players DatabaseObject from the PlayerObjects table. I wanted to try and store information about each players character (Class, Level, Xp, etc) in an object called "Character". I added a new object to the PlayerObjects table called "Character" and then added a string property called "Class" with a default value of "Novice". I then saved the changes.

The problem is that I am unable to load this "Class" information from the "Character" object using the DatabaseObject given to me by the callback function for loadMyPlayerObject. Here is the code I am using...

Code: Select all
public function MenuState(client:Client)
      {
characterInfo = new Label("",12, TextFormatAlign.CENTER)
client.bigDB.loadMyPlayerObject(loadPlayerSuccess)
}
private function loadPlayerSuccess(ob:DatabaseObject):void
{
   characterInfo.text = "Class: " + ob.Character.Class
}


I get a " A term is undefined and has no properties." error in FlashDevelop. I have looked at the BigDB pages and examples but I can't figure out what Im doing wrong. What am I missing?
getAcross
Paid Member
 
Posts: 3
Joined: May 1st, 2011, 9:09 pm

Re: LoadMyPlayerObject Confusion

Postby getAcross » May 1st, 2011, 10:07 pm

Never mind, I figured it out. I simply misunderstood how a noSQL database works.
getAcross
Paid Member
 
Posts: 3
Joined: May 1st, 2011, 9:09 pm

Re: LoadMyPlayerObject Confusion

Postby Henrik » May 1st, 2011, 10:30 pm

getAcross wrote:I added a new object to the PlayerObjects table called "Character" and then added a string property called "Class" with a default value of "Novice".

BigDB is schemaless, there's no defined structure to the objects saved, so if you made one object in the table that had some properties, that does not affect any other objects in the table.

This means you can't have any default values or similar setup beforehand. What you can do is check for properties and set your defaults when you create a user.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm


Return to BigDB



cron