-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
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
Metadata
Metadata
Assignees
Labels
No labels