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

Delete improvement when clearing the database #448

Open
alinpetrus opened this issue Mar 8, 2022 · 1 comment
Open

Delete improvement when clearing the database #448

alinpetrus opened this issue Mar 8, 2022 · 1 comment

Comments

@alinpetrus
Copy link

We are using CoreStore and while we love it, there is one thing that is causing us a bit of trouble. When wanting to clear the whole database, we need to go through all the entities and do calls to deleteAll for each entity.
For large datasets this is fairly time consuming.

I am wondering if we could have something which is faster like using NSBatchDeleteRequest or a call to destroyPersistentStore on each store and recreating them afterwards.

@JohnEstropia
Copy link
Owner

@alinpetrus Thanks. Should be simple enough to expose a safe method for it (since cs_eraseStorageAndWait() already exists for the purpose of migrations). The hard part is ensuring that the existing observers are notified of the deletions. I'll try to push a prototype into develop this weekend and let you play with it before we merge it to main.

In the mean time, if you can ensure that all references to the DataStack can be initialized, you can just replace your DataStack with a new one, delete the files related to the old SQLiteStore().fileURL, and re-add the SQLiteStore to the new DataStack. I have two projects that does this safely, but yeah we should have a supported safe way to remove stores in the API.

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

No branches or pull requests

2 participants