LiveCloud Forums
searcheable / queryable arrays stored in keys? - Printable Version

+- LiveCloud Forums (https://forums.livecloud.io)
+-- Forum: General (https://forums.livecloud.io/forumdisplay.php?fid=1)
+--- Forum: General (https://forums.livecloud.io/forumdisplay.php?fid=3)
+--- Thread: searcheable / queryable arrays stored in keys? (/showthread.php?tid=434)



searcheable / queryable arrays stored in keys? - sid - 05-16-2020

Hi Guys

this is more a question im sure a lot of devs will ask.

If a dev decides to store arrays in a key within livecloud, is it then possible to run a query on the database and include results that are within the array key?

for example, if I were to store invoices as a DGData array in a key called invData, and 3 of the keys in within the stored array is productBought =20 , Customer = Sid, Item=Mask

I want to run a query looking for invoices that were made out to Sid for masks , and want only invoices where he bought over 10 masks.

this is really easy to do if each line item is stored seperately in the livecloud database, but if you store the invoice data as and array key within a key in the database , can it work?

the upside to being able to do this is that the database is nice and compact with each invoice or whatever taking up a single record ,

the downside is the queries being difficult to do, if its possible at all

The upside to storing all the line items as seperate records is the ease of search, and the ability to run really cool queries.
the downside being that individual line items will take up a record and be scattered all over the plave, resulting in zillions of records and writes to the database

Sid


RE: searcheable / queryable arrays stored in keys? - mark_talluto - 05-18-2020

Hi Sid,

No queries can be made to a key that contains an array. It would be cool to be able to do that. It would have a negative hit on the performance of the query. You laid at the pros and cons very well.

If you wanted to embrace storing full arrays in a single key, you could store meta data on a separate table that you linked to the full array in another table. You could query the meta data and have a key that stored the recordID to the full array in the other table. This could give you a working solution.


RE: searcheable / queryable arrays stored in keys? - sid - 05-19-2020

Hi Mark

Thanks for the clarification. I will plan accordingly.

Sid