Expand the driver support for IndexedDB #13
Replies: 1 comment 2 replies
-
Hi @petarblazevski, Sorry for the late reply since last week has been a busy week. Thank you for your thoughtful feedback and for sharing your use case! 😊 The plugin’s primary focus is on simplifying state persistence for Pinia stores by treating storage mechanisms (like Regarding schema and data migration, here’s why it’s not directly addressed in the plugin:
Here’s how you might use a custom storage implementation with the plugin: import { createPinia } from 'pinia';
import { createStatePersistence } from 'pinia-plugin-state-persistence';
import Dexie from 'dexie';
const db = new Dexie('MyDatabase');
db.version(1).stores({ data: 'key' }); // Define your schema
const customStorage = {
async getItem(key) {
return (await db.table('data').get(key))?.value || null;
},
async setItem(key, value) {
await db.table('data').put({ key, value });
},
async removeItem(key) {
await db.table('data').delete(key);
},
};
const pinia = createPinia();
pinia.use(createStatePersistence({ storage: customStorage })); This setup lets you leverage We’re always open to improving the plugin, so if you have additional ideas or specific features in mind, feel free to share. Thanks again for your suggestion and support! 🚀 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I recently started using this plugin, and it's exactly what I needed—great work! However, I noticed a missing feature that's essential for my use case: schema and data migration.
The current driver for IndexedDB, localForage, doesn't seem to support this functionality.
Previously, I implemented a custom solution using the IDB wrapper to interact with IndexedDB. IDB's built-in upgrade functionality made handling migrations straightforward.
It would be fantastic if this plugin could support similar migration capabilities, perhaps by integrating with IDB or Dexie.js. Adding such a feature would make this tool even more versatile and powerful.
Thanks for considering this suggestion, and keep up the great work!
Beta Was this translation helpful? Give feedback.
All reactions