question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

realm.deleteAll() does not delete stale data

See original GitHub issue

Goals

When I remove a model and update the schema, I would love to clean up the data as well.

Expected Results

realm.deleteAll() would remove all data, no matter if it is in the schema or not.

Actual Results

The data of the deleted model still persists.

Steps to Reproduce

If I had a Car model, but the new schema got rid of it. Even after I call realm.deleteAll(), the stale data from the old Car model still exists.

Code Sample

Version of Realm and Tooling

  • Realm JS SDK Version: 1.3.1
  • Node or React Native: react-native 0.44.0
  • Which debugger for React Native: None

Right now I am deleting the .realm file before initializing to get rid of the stale data, but it seems to me that realm.deleteAll() should mean a clean slate with the new schema and without any stale data like this.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
ashwinphatakcommented, Sep 12, 2017

Merged 532f517, which exposes a deleteModel method to be used during migrations.

1reaction
hyb175commented, Sep 12, 2017

Thank you! @ashwinphatak

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does Realm deleteAll() Reset Primary Keys - Stack Overflow
1 Answer 1 ... Realm.deleteAll() removes all objects stored in the Realm. The values of primary key properties must be unique amongst objects ......
Read more >
CRUD - Delete - React Native SDK — Realm - MongoDB
To delete all objects from the realm, call Realm.deleteAll() inside of a write transaction. This clears the realm of all object instances but...
Read more >
Why do I get an error when deleting data from SwiftUI List and ...
write is the Realm syntax to be able to perform changes to the database. I'm deleting results[0] when a button is tapped just...
Read more >
Realm clear all data
By calling this method, all Realm files are deleted, which means all objects & schemas are gone. Catching all exceptions is a bad...
Read more >
Delete index API | Elasticsearch Guide [8.5] | Elastic
Deleting an index deletes its documents, shards, and metadata. It does not delete related Kibana components, such as data views, visualizations, or dashboards....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found