Home > database >  Is it possible to temporarily remove an item from RecyclerView that is connected to Firestore DB?
Is it possible to temporarily remove an item from RecyclerView that is connected to Firestore DB?

Time:11-12

On the online voting system that I am currently working on, I am preparing for the voting feature. I plan to remove an item from the RecyclerView that the user has already voted on but in a way that it does not remove it from the Firestore database itself. Is there a way to do that? If not, is there any workaround to make my concept work? Thank you in advance for the responses.

CodePudding user response:

I plan to remove an item from the RecyclerView that the user has already voted on but in a way that it does not remove it from the database itself.

The simplest solution would be to add a field of type boolean with the default value of false, into each document. You can simply call it "deleted". When you want to perform a delete operation, don't remove the document from the database, rather change its value from false to true.

If you want to have a temporary removal, you might also consider moving a document from a location to another.

If not, is there any workaround to make my concept work?

You can also use Cloud Functions, to trigger a function that contains a particular logic, when a delete operation takes place.

  • Related