sindresorhus/conf

How to handle arrays?

bloodchen opened this issue · 4 comments

Let's say I have a config

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

How can I add an item to items array?

Thanks

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

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

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

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