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

Store.clear() clears ALL stores #243

Open
vothvovo opened this issue Dec 1, 2022 · 3 comments
Open

Store.clear() clears ALL stores #243

vothvovo opened this issue Dec 1, 2022 · 3 comments

Comments

@vothvovo
Copy link

vothvovo commented Dec 1, 2022

Is this intended? I feel like it is unintuitive.

@pierretusseau
Copy link

Yes as explained in the README :

.reset(...keys)

Reset items to their default values, as defined by the defaults or schema option.

Use .clear() to reset all items.

@sindresorhus
Copy link
Owner

sindresorhus commented Dec 1, 2022

@JoanVicens
Copy link

I think the problem @vothvovo faced is that when you create 2 different stores they will overwrite each other. I assume it's because they share the same config.json file. I tried it myself on this demo project to validate it.

const Store = require('electron-store');

const store1 = new Store();
const store2 = new Store();


store1.set('unicorn', '🦄');
store2.set('unicorn', '🦄');

console.log(store1.get('unicorn'));
//=> '🦄'
console.log(store2.get('unicorn'));
//=> '🦄'

store1.clear();

console.log(store1.get('unicorn'));
//=> undefined
console.log(store2.get('unicorn'));
//=> undefined

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

No branches or pull requests

4 participants