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

how to rename a store? #377

Open
jonasbernardo opened this issue Apr 12, 2024 · 2 comments
Open

how to rename a store? #377

jonasbernardo opened this issue Apr 12, 2024 · 2 comments

Comments

@jonasbernardo
Copy link

No description provided.

@alextekartik
Copy link
Collaborator

There is unfortunately no way to rename a store. You have to copy/delete all the records using something like:

// old store
var store1 = intMapStoreFactory.store('store1');
// new store
var store2 = intMapStoreFactory.store('store2');
await db.transaction((txn) async {
  /// Read all records from store1 and write them to store2
  var records = await store1.find(txn);
  for (var record in records) {
    await store2.record(record.key).put(txn, record.value);
    // Delete existing record
    await store1.record(record.key).delete(txn);
  }
});

@jonasbernardo
Copy link
Author

Thanks for the answer, I'm going to start using seambast in my projects

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