sindresorhus / conf

Simple config handling for your app or module
MIT License
1.23k stars 124 forks source link

How to handle arrays? #109

Open bloodchen opened 4 years ago

bloodchen commented 4 years ago

Let's say I have a config

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

How can I add an item to items array?

Thanks

sindresorhus commented 4 years ago

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: https://github.com/sindresorhus/electron-store/issues/52

Nisthar commented 4 years ago

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

sindresorhus commented 4 years ago

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

sindresorhus commented 3 years ago

For anyone wanting to work on this, see the initial attempt and feedback in: https://github.com/sindresorhus/conf/pull/124