Forum BigDB creating and adding nested objects

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

creating and adding nested objects

Postby carsonmorton » May 22nd, 2012, 9:46 pm

i want to create a database object serverside. I then want to create it in bigDB using PlayerIO.BigDB.CreateObject()
this is what I'm doing so far:
Code: Select all
var newThing = new DatabaseObject();
newThing.Set(blah blah blah)
PlayerIO.BigDB.CreateObject("myTable", ????????, newThing, null);

i just dont know how to create it under a parentObject (which is already part of myTable) without writing over any childObjects that may already be there
carsonmorton
 
Posts: 39
Joined: April 24th, 2012, 3:12 am

Re: creating and adding nested objects

Postby deadbug » May 23rd, 2012, 8:59 am

the ?? would be null in which case BigDB will auto assign a key or when you want to provide a key, "yourUniqueKey" :)
deadbug
 
Posts: 35
Joined: November 1st, 2011, 1:35 am

Re: creating and adding nested objects

Postby carsonmorton » May 23rd, 2012, 6:05 pm

if I wanted to give it a specific key I would just make ??? this: "parentObject.iNamedThisKey"

I want to nest it AND have it give it a unique key: "parentObject.uniqueKey"...
carsonmorton
 
Posts: 39
Joined: April 24th, 2012, 3:12 am

Re: creating and adding nested objects

Postby deadbug » May 23rd, 2012, 10:00 pm

Not sure that makes sense.
If you want it to be nested, add it to the parent object as an object / array if thats what you want.

also as mentioned, the key must be globally unique, which with your naming does not needfully seem to be granted but I might be wrong on this point.
deadbug
 
Posts: 35
Joined: November 1st, 2011, 1:35 am

Re: creating and adding nested objects

Postby carsonmorton » May 23rd, 2012, 11:16 pm

I dont know enough programming to really make much sense in the first place...

lets see if I can explain what I'm doing:

in each zone players will be able to pick x/y coordinates to hide/geocache loot.
I have a lootTable in bigDB. each zone has a databaseObject in the lootTable that will hold all the hidden loots.
when the server gets a "i hid loot" message it will create a new databaseObject and nest it into the appropriate zoneObject
Code: Select all
DatabaseObject lootObject= new DatabaseObject();
lootObject.Set("x", xFromMessage);
lootObject.Set("y", yFromMessage);
PlayerIO.BigDB.Load("lootTable", zoneKey, delegate(DatabaseObject zoneObject)
{
     zoneObject.Set(null, lootObject); // will null generate the desired unique key?
     // do I need to Save() my lootObject? or will setting it have saved it already?
}

I don't really know what I'm doing, but that's what I've been able to cobble together today. am I even on the right track?

next I want a player to be able to serch at a given x/y coordinate.
the server will pull all the hidden loots from the zone
I'll need to iterate through them to find the one that is closest, and remove it from the zoneObject
carsonmorton
 
Posts: 39
Joined: April 24th, 2012, 3:12 am


Return to BigDB