Forum BigDB DeleteRange format

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

DeleteRange format

Postby azuanagames » October 27th, 2010, 3:25 am

Am I doing this right? I'm pretty sure I just delete the wrong stuff ;0

PlayerIO.BigDB.DeleteRange("Referrals", "ByWhen", null, DateTime.UtcNow.AddMonths(-6), null);

I meant to delete things older than 6 months... Does this say to delete starting 6 months ago to today? Sure looks like I'm clearing the table every time... :(
azuanagames
 
Posts: 157
Joined: April 29th, 2010, 10:59 pm

Re: DeleteRange format

Postby Oliver » October 27th, 2010, 1:25 pm

What does the index "ByWhen" look like for the table?
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: DeleteRange format

Postby azuanagames » October 27th, 2010, 4:20 pm

when (Date, Ascending)

Guess it should be descending?
azuanagames
 
Posts: 157
Joined: April 29th, 2010, 10:59 pm

Re: DeleteRange format

Postby Oliver » October 28th, 2010, 9:35 am

Date ascending sounds correct... Hm... I'll get some tests done on it, to see if we can reproduce it.

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: DeleteRange format

Postby azuanagames » November 4th, 2010, 6:35 pm

Any results yet?
azuanagames
 
Posts: 157
Joined: April 29th, 2010, 10:59 pm

Re: DeleteRange format

Postby Oliver » November 5th, 2010, 3:35 pm

Hey,

I'm an idiot. There is no bug.

You have an index storing values in ascending order:

1 (let's consider this 10 months ago)
2
3
4
5
6
7
8
9
10 (let's consider this "now")

When you say:
PlayerIO.BigDB.DeleteRange("Referrals", "ByWhen", null, DateTime.UtcNow.AddMonths(-6), null);

What you're saying in plain english is: delete all objects in the Referrals table using the ByWhen index for all values in the range from -6 months and forward.

So, that looks like this

1 (let's consider this 10 months ago)
2
3
4 <-- Start deleting here
5 <-- delete and move forward
6 <-- delete and move forward
7 <-- delete and move forward
8 <-- delete and move forward
9 <-- delete and move forward
10 <-- delete and move forward (no more entries, so stop)

If you want to delete everything older than 6 months, you have to do:
PlayerIO.BigDB.DeleteRange("Referrals", "ByWhen", null, null, DateTime.UtcNow.AddMonths(-6));

A hit for the future, use the LoadRange method to test if your range returns the correct values. If it works, just change it to a call to DeleteRange.

Sorry for the long response time.

Best,
Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: DeleteRange format

Postby azuanagames » November 5th, 2010, 4:50 pm

Sounds great, I was a bit confused, but makes sense now.
azuanagames
 
Posts: 157
Joined: April 29th, 2010, 10:59 pm

Re: DeleteRange format

Postby Oliver » November 5th, 2010, 5:07 pm

Again, sorry i didn't catch this straight away...
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am


Return to BigDB



cron