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

collection.removeCollection does not get autosaved into persisted DB #185

Open
cepm-nate opened this issue Sep 27, 2020 · 1 comment
Open

Comments

@cepm-nate
Copy link

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/LokiJS-Forge/LokiDB/blob/master/CONTRIBUTING.md#question

Current behavior

When you remove a collection, the 'autosave' does not pick up the change.

Expected behavior

I would expect autosave to pick up the change, so that the deletion of the collection is properly persisted.

Minimal reproduction of the problem with instructions


const idbAdapter = new IndexedStorage(dbName);
const db = new Loki('dbfile');
let persistenceOptions = {
	adapter: idbAdapter,
	autosave: truep,
	autosaveInterval: 900, // 900ms.
	autoload: true,
	throttledSaves: false,
};
wdb.initializePersistence(persistenceOptions)
.then((r) => {
	console.log('Done loading.');
	const collection = db.addCollection(`Test_500`);
	collection.insert({ foo:'bar' });
	setTimeout(() => {
		// So autosave has run
		db.removeCollection('Test_500');
		setTimeout(() => {
			// so autosave has had time to do it's thing again
			console.log('Collections in db:', db._collections.length);
			console.log('Collections last persisted', db._persistenceAdapter._dbref._collections.length);
			console.log('Check DevTools  Application storage. The DB should be EMPTY.');
		}, 2000);
	},2000);
})

What is the motivation / use case for changing the behavior?

In my mind, deletion of data should "stick", and not show up again if the browser is refreshed. In my project I can work around it by 'clearing' a collection instead of deleting and re-creating it, but this does feel like a bug that should be tracked.

Environment


LokiDB version: 2.1.0
Browser/Node version: Browser X.Y.Z.
@greaterking
Copy link

greaterking commented Jan 8, 2021

Confirming this issue as well. I have similar setup using adaptor.

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

2 participants