ammarahm-ed / react-native-mmkv-storage

An ultra fast (0.0002s read/write), small & encrypted mobile key-value storage framework for React Native written in C++ using JSI
https://rnmmkv.now.sh
MIT License
1.58k stars 109 forks source link

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

Open cani1see opened 2 years ago

ammarahm-ed commented 2 years ago

Can you provide more details and an example

cani1see commented 2 years ago

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.

ammarahm-ed commented 2 years ago

@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.

cani1see commented 2 years ago

@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.

ammarahm-ed commented 2 years ago

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