TheCocoaProject / cordova-plugin-nativestorage

Cordova plugin: Native storage of variables in Android, iOS and Windows
http://thecocoaproject.github.io/
Apache License 2.0
292 stars 106 forks source link

Get all keys for items in storage? #56

Closed alexfoxy closed 7 years ago

alexfoxy commented 7 years ago

I'm storing a bunch of saved projects on an app I'm working on. When the user boots up I want to get all of their projects and list them. Previously I was saving the projects as JSON (stringified) to localStorage and pulling them out when the app booted up e.g:

for(var key in localStorage) {
    ...
}

I can't see a way to do something similar with NativeStorage. Would you suggest keeping an index in storage e.g. "project_ids" instead?

Thanks, Alex

GillesC commented 7 years ago

If you're always retrieving all the projects you could just store these projects in an array. Which can also be stored via NativeStorage.

GillesC commented 7 years ago

This feature is now implemented by @ydeshayes (through PR #61)

alexfoxy commented 7 years ago

Great, I did it the way you suggested any way but this will be useful in the future 👍