Forum BigDB LoadRange question

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

LoadRange question

Postby gnollik » February 22nd, 2012, 12:48 am

Hi! Sorry about this newbie question but I cant find an example how to do what I need.

In short: I have 100 maps, each map has 2 properties - 1st is date when it was created and 2nd is approved the map or not, or in proccess. So "approve" property can be 0, 1 or 2.

I need to load first 10 maps that was created last and that already approved. I`m already create an index to sort all maps by date, but I dont understand how to check "approve" property.

My current code:

Code: Select all
this.start_client.bigDB.loadRange("crimson", "creation", null, null, null, 10,
function(info:Array):void
{
...save results in my array...
}
});


how I can declare in the request that I need maps with approve = 1, not other?
gnollik
Paid Member
 
Posts: 24
Joined: March 12th, 2011, 10:08 pm

Re: LoadRange question

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

You need to make the index over approve (ascending) and date (descending), and then you call loadrange like this:

Code: Select all
this.start_client.bigDB.loadRange("crimson", "creation", [1], null, null, 10, ...
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: LoadRange question

Postby gnollik » February 22nd, 2012, 4:58 pm

Ok, I created an index like you told:

index.jpg
index.jpg (12.79 KiB) Viewed 10916 times


And try to use this request:

Code: Select all
this.start_client.bigDB.loadRange("crimson", "creation", [2], null, null, 6,
function(info:Array):void
{
...


I`m use [2] because "2" corresponds to the approved status of the map. But I dont get anything...
gnollik
Paid Member
 
Posts: 24
Joined: March 12th, 2011, 10:08 pm

Re: LoadRange question

Postby Henrik » February 22nd, 2012, 6:42 pm

The order of the properties in the index is very important, that's why I said you should put the date last. :-)

When your properties are in that order, your loadRange call means that it should get the objects where the create_date is "2", and that's not true for any of them. But if you flip the properties in your index, the same call means it should get the objects where map_status is "2", in the order of the remaining properties, which is create_date descending, which is what you wanted.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: LoadRange question

Postby gnollik » February 22nd, 2012, 7:38 pm

Ok, It works fine now. Thanks!
gnollik
Paid Member
 
Posts: 24
Joined: March 12th, 2011, 10:08 pm


Return to BigDB