react-native-mmkv-storage icon indicating copy to clipboard operation
react-native-mmkv-storage copied to clipboard

[Question]how to setArray, query one array item by specific property

Open cani1see opened this issue 2 years ago • 5 comments

cani1see avatar Jun 10 '22 13:06 cani1see

Can you provide more details and an example

ammarahm-ed avatar Jun 12 '22 03:06 ammarahm-ed

Can you provide more details and an example

In the document only shows setArray then getArray, but mostly query one item (by id meybe) is all we need. If instead use id as key to setMap, I find it's very cpu comsuming when the array is large.

cani1see avatar Jun 12 '22 16:06 cani1see

@cani1see you should organize your database in a better way to improve performance of key-value store. The best way is to index items by id and then save each item separately instead of in a one big array. Keep an array of all keys which can be used to find items you need later.

ammarahm-ed avatar Jun 12 '22 19:06 ammarahm-ed

@cani1see you should organize your database in a better way to improve performance of key-value store. The best way is to index items by id and then save each item separately instead of in a one big array. Keep an array of all keys which can be used to find items you need later.

as long as I'm setting array item separately, I find it's very time consuming when the array length is large, I think it would be better if there is a way to pass the array once, let the looping happen in native side.

cani1see avatar Jun 13 '22 04:06 cani1see

@cani1see Can you provide an example of data and how you are storing it?

ammarahm-ed avatar Jun 28 '22 14:06 ammarahm-ed