Forum BigDB How to delete all of the objects in bigdb using c#?

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

How to delete all of the objects in bigdb using c#?

Postby 12345hassan » November 4th, 2018, 5:16 am

The Title explains it all. I made a top10 active list in my game and i want to reset it every week it uses index "active". But from DeleteKeys its too difficult to delete every single object caz there are more than 300 objects and I can't make 300lines for 300 please help
12345hassan
 
Posts: 39
Joined: August 5th, 2016, 11:40 am

Re: How to delete all of the objects in bigdb using c#?

Postby Henrik » November 8th, 2018, 7:04 am

Wouldn't it be much easier to store the week in the objects, and make an index over that as well? That way you just add the current week when you write your scores, and use the index to read scores for the current week.

One simple way to store a week is to store midnight of Monday of the current week as a DateTime. As a bonus, you can get monthly and yearly toplists out of the same BigDB table as well.
Henrik
.IO
 
Posts: 1805
Joined: January 4th, 2010, 1:53 pm

Re: How to delete all of the objects in bigdb using c#?

Postby 12345hassan » November 9th, 2018, 5:39 pm

Sorry I didn’t understand what you mean. My question is how can I truncate / delete all created objects of a table from my c# when the time of reset is over I have todo it myself from big db isn’t their a way to do it automatically? Delterange gives problem that the property Is int of onlineTime if I convert it to string it won’t add minutes.
12345hassan
 
Posts: 39
Joined: August 5th, 2016, 11:40 am

Re: How to delete all of the objects in bigdb using c#?

Postby Henrik » November 11th, 2018, 1:27 am

My solution to your problem was to simply not do any deletes at all. Instead of treating your table as a single list of most active users for the current week, where you clear it out every week, another solution is to treat it as multiple lists of users, and using indexes to read the current week's list and simply ignoring past weeks. Same result.

But if you really want to delete everything in the table every week, that's certainly possible using DeleteRange, you just need to make sure there is an index that covers all objects, and you should be good. If you have a property in your index that is an int, then call DeleteRange with 0 as the start and MaxInt as the stop, and it should match all objects and delete them.
Henrik
.IO
 
Posts: 1805
Joined: January 4th, 2010, 1:53 pm

Re: How to delete all of the objects in bigdb using c#?

Postby 12345hassan » November 15th, 2018, 4:12 pm

Error: The start index value of property onlineTime is smaller than the stop value
Code:
PlayerIO.BigDB.DeleteRange("MYDBNAME", "active", null, 0, int.MaxValue);
12345hassan
 
Posts: 39
Joined: August 5th, 2016, 11:40 am

Re: How to delete all of the objects in bigdb using c#?

Postby Henrik » November 16th, 2018, 11:48 pm

If your index is sorted Descending, you need to flip the 0 and int.MaxValue.
Henrik
.IO
 
Posts: 1805
Joined: January 4th, 2010, 1:53 pm

Re: How to delete all of the objects in bigdb using c#?

Postby 12345hassan » November 17th, 2018, 7:57 am

Thank you for your reply, I will try that as soon as I can, is there a way to give the top 3 prizes?
The top 3 players on the index I want to give them prizes from another table like
Loads top 3 players
Loads the other tables objects of those three
Save their with prizes
Then it delete all objects.
12345hassan
 
Posts: 39
Joined: August 5th, 2016, 11:40 am

Re: How to delete all of the objects in bigdb using c#?

Postby 12345hassan » November 17th, 2018, 9:27 am

The delete is working thank you.
12345hassan
 
Posts: 39
Joined: August 5th, 2016, 11:40 am

Re: How to delete all of the objects in bigdb using c#?

Postby 12345hassan » November 24th, 2018, 7:24 am

12345hassan wrote:Is there a way to give the top 3 prizes?
The top 3 players on the index I want to give them prizes from another table like
Loads top 3 players
Loads the other tables objects of those three
Save their with prizes
Then it delete all objects.
12345hassan
 
Posts: 39
Joined: August 5th, 2016, 11:40 am

Re: How to delete all of the objects in bigdb using c#?

Postby Henrik » November 25th, 2018, 2:48 am

If you have a BigDB Table that contains scores per user, and you want to load the top 3, you need a descending index on the table over the score property, and then you can load the top 3 something like this:

Code: Select all
LoadRange("the table", "the new index", null, null, null, 3, ...)

That gets you the three first objects in the index, and since it's descending and over the score, the first three should be the top 3, which is what you wanted.
Henrik
.IO
 
Posts: 1805
Joined: January 4th, 2010, 1:53 pm

Re: How to delete all of the objects in bigdb using c#?

Postby 12345hassan » November 25th, 2018, 7:03 am

Henrik wrote:If you have a BigDB Table that contains scores per user, and you want to load the top 3, you need a descending index on the table over the score property, and then you can load the top 3 something like this:

Code: Select all
LoadRange("the table", "the new index", null, null, null, 3, ...)

That gets you the three first objects in the index, and since it's descending and over the score, the first three should be the top 3, which is what you wanted.

How can I give them prizes from other table , here is what i want to do:
Timer ends ( Done )
Loads top3 ( Code Above )
Give them prizes from other table like load the top 3 from STTableofActive and Edit there object in STTableofItems ( Not Done )
Delete all topics ( Done )
The prizes is only left
12345hassan
 
Posts: 39
Joined: August 5th, 2016, 11:40 am

Re: How to delete all of the objects in bigdb using c#?

Postby Henrik » November 26th, 2018, 10:26 pm

If you've loaded the top three users, you have their connectuserid, I guess? Or something that you use as key for each user. And if you're using that same key in the other table, then just call https://playerio.com/documentation/refe ... b#loadKeys which takes an array of keys, and then you'll get those three objects from that table.
Henrik
.IO
 
Posts: 1805
Joined: January 4th, 2010, 1:53 pm


Return to BigDB



cron