Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle arrays? #109

Open
bloodchen opened this issue Apr 29, 2020 · 4 comments
Open

How to handle arrays? #109

bloodchen opened this issue Apr 29, 2020 · 4 comments

Comments

@bloodchen
Copy link

bloodchen commented Apr 29, 2020

Let's say I have a config

{
   "items":[ {"name":"abc"},{"name":"dadd"}]
}

How can I add an item to items array?

Thanks

@sindresorhus
Copy link
Owner

There's currently no nice way to do this. You'll have to do something like:

store.set('items', [...store.get('items'), newItem]);

I plan to add a convenience method for this. See: sindresorhus/electron-store#52

@Nisthar
Copy link

Nisthar commented Jul 23, 2020

@sindresorhus Doesn't this cause performance issues when the array is big?

@sindresorhus
Copy link
Owner

Only for huge arrays, and you should not store huge chunks of data in conf anyway.

@sindresorhus
Copy link
Owner

For anyone wanting to work on this, see the initial attempt and feedback in: #124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants