-
Notifications
You must be signed in to change notification settings - Fork 572
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
Need a way to reset Realm db Models #6009
Comments
@somasekharkakarla Can you clarify what you mean by "reset"? Currently you can use |
Hi @takameyer, For an example: we have 5 models if we want to clear the object in these Models
Now all Objects are deleted in the model which i call a reset of model if we can introduce reset(['Model1', 'Model2']) and resetAll() function. we can achieve it very fast instead of writing long code now code will be if i want to reset all |
@somasekharkakarla it's an interesting idea, but very specialized. You could write these as helper functions in your own application:
I don't see how |
Delete all will delete including Model. No model will be there in db right. Yes i can write a helper function. Its not that important but just if we have one it will great |
And also @takameyer can you please look into it |
We can create small aux. methods for resetAll() => this.schema.forEach((s) => this.delete(this.objects(s.name)); |
Great |
Hi @kneth |
Hi @kneth , any update on this? |
Problem
Currently we have deleteAll() method in realm which help use to delete all models from realm. But there are N number of use case where we need a way to reset the db instead deleting the models. By now, we can only do it a way getting all objects and delete it.
But we need a way to reset the model without we do all this.
For example: if a user change from one region to another. We need to remove all pref and data from the region and add new data. If we use deleteAll() it also losing the it reference which causing errors.
Solution
Implementation of resetAll() and reset(['Model1', 'Model2']) which helps to reset data instead of calling a objects of all models and deleting it.
Alternatives
No response
How important is this improvement for you?
Would be a major improvement
Feature would mainly be used with
Local Database only
The text was updated successfully, but these errors were encountered: