Forum BigDB loadKeys first-timer

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

loadKeys first-timer

Postby carsonmorton » July 13th, 2012, 9:03 pm

Ok, trying to use loadkeys for the first time. I dont understand what the documentation means by: Callback<DatabaseObject[]> successCallback

well... i understand it's a callback with an array of objects in the same order as the keys, but I dont understand how to put that into code, and I dont see any direct examples

Code: Select all
PlayerIO.BigDB.LoadKeys("tableName",
     new String[]{"firstKey", "secondKey")},
     //
     delegate(new DatabaseObject[]{DatabaseObject firstObject, DatabaseObject secondObject})
          {
               // do something with the delegate objects
          });
carsonmorton
 
Posts: 39
Joined: April 24th, 2012, 3:12 am

Re: loadKeys first-timer

Postby Henrik » July 14th, 2012, 12:50 am

The LoadRange methods also have a callback that gets an array of databaseobjects, so there's some documentation, but you are correct that there is no example specifically for LoadKeys:

http://playerio.com/documentation/refer ... rary.bigdb

The correct way to use LoadKeys is like this:

Code: Select all
PlayerIO.BigDB.LoadKeys("tableName",
    new String[]{ "firstKey", "secondKey" },
    delegate(DatabaseObject[] result) {
        //And then you can loop over your results like this:
        foreach (var obj in result) {
            if (obj != null) {
                //Do something with each object...
            }
        }

        //Or you can grab a specific one:
        var firstObj = result[0]; //firstKey
        var secondObj = result[1]; //secondKey
    }
);
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: loadKeys first-timer

Postby carsonmorton » July 17th, 2012, 10:43 pm

thanks!
carsonmorton
 
Posts: 39
Joined: April 24th, 2012, 3:12 am

Re: loadKeys first-timer

Postby johannes » April 26th, 2013, 8:50 pm

i understand it's a callback with an array of objects in the same order as the keys


It would be sweet if the documentation said this, so it official (and I didn't have to google it).
johannes
 
Posts: 2
Joined: July 6th, 2012, 8:37 pm


Return to BigDB



cron