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.

Missing feature: delete by id

See original GitHub issue

I’m using Realm and I really miss the feature of deleting objects using thier Ids, the way we’ve right now is:

realm.write(() => {
  // Create a book object
  let book = realm.create('Book', {id: 1, title: 'Recipes', price: 35});

  // Delete the book
  realm.delete(book);

  // Delete multiple books by passing in a `Results`, `List`,
  // or JavaScript `Array`
  let allBooks = realm.objects('Book');
  realm.delete(allBooks); // Deletes all books
});

But I see that it’d be handy to delete by just passing the id:

realm.write(() => {
  // Create a book object
  let book = realm.create('Book', {id: 1, title: 'Recipes', price: 35});

  // Get the book id
  let bookId = book.id;

  // Delete the book
  realm.delete('Book', bookId);
  // or
  realm.delete(bookId);
});

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:9
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

13reactions
alaziercommented, Mar 27, 2017

Right now the easiest way to do this:

realm.delete(realm.objectForPrimaryKey('Book', bookId));
3reactions
Dhirajbhujbalcommented, May 11, 2019

Excellent @alazier your solution has been worked @lossen Could you please this

` realm.write( () => {

realm.delete(realm.objectForPrimaryKey(‘Book’, bookId));

})

`

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to delete all the missing feature and set up files reported ...
Hi Krishna,. You can use PowerShell code to remove the missing features. There is a similar blog, you can refer to it:.
Read more >
2016 - Cannot find MissingFeature to remove it from a Content ...
However the only place I can find a reference to this Feature Id is in the database itself under the FeatureTracking table. I...
Read more >
Delete Missing Features – dig deeper - soumyabhatta
I have been tasked with deleting missing features from existing farm. ... Parameter name: Could not find Feature Your Feature Id.”
Read more >
How to remove orphaned (missing) SharePoint Features with ...
Running the Script above will remove all of the missing Features from all of the Site Collections as well as each Sub Site....
Read more >
Remove Missing Features From Content Database - C# Corner
The feature with Id xxx-xxxxxx-xxxxxx-xxxxx is referenced in the database [SharePoint_Content_Portal], but is not installed on the current ...
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