Forum BigDB Find string in DatabaseArray

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

Find string in DatabaseArray

Postby burletech » June 7th, 2013, 12:27 am

Hey. Been looking for an answer to this for awhile and couldn't find it in the docs. It's probably there but I'm to dense to find it.

I have a DatabaseObject with a with an array of players names (string). I want a player to be able to find all the objects in a table where their name appears in this array. What would be the best way of going about this?

I tried doing an index but index doesn't have an Array option. No luck there but perhaps I'm using it wrong?

Any help would be great. Thanks!
burletech
 
Posts: 3
Joined: June 3rd, 2013, 10:22 pm

Re: Find string in DatabaseArray

Postby burletech » June 9th, 2013, 5:45 pm

So is finding a string in an array though Indexes not possible? Or am I just not doing something right?

Screen Shot 2013-06-09 at 9.32.15 AM.png
Screen Shot 2013-06-09 at 9.32.15 AM.png (47.63 KiB) Viewed 10089 times


I as hoping this would allow me to find player's inside this array.

Screen Shot 2013-06-09 at 9.40.15 AM.png
Screen Shot 2013-06-09 at 9.40.15 AM.png (8.29 KiB) Viewed 10089 times


Obviously it works fine for strings that aren't in an array but it doesn't return anything for arrays. Is there any way to make this work that I'm missing? Thanks!

Note: I'm currently just adding a unique id to each match the player is a part of to a string array in the PlayerObjects DB. Then just pull up each database obj that has a matching id. This works but I'd prefer to be able to to use a search index to find a player inside a string array of names held in a DBObject. Does that make any sense or am I not being clear?
burletech
 
Posts: 3
Joined: June 3rd, 2013, 10:22 pm

Re: Find string in DatabaseArray

Postby Henrik » June 10th, 2013, 9:13 am

No, it's not possible to use BigDB indexes in the way you are describing.

To solve your problem, I think you have to do a reverse lookup. Instead of adding a player to an array in object X, add key X to an array on the player object. That way you can look at the player object, get the list of keys, and then LoadKeys to get all those objects.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Find string in DatabaseArray

Postby burletech » June 10th, 2013, 4:37 pm

Thanks Henrik for the response. Good idea that'd be much more efficient than what I'm doing now. You rock!
burletech
 
Posts: 3
Joined: June 3rd, 2013, 10:22 pm


Return to BigDB