Delete functionality also the restore functionality same table

I want functionality where delete function call then the database record delete, also that record will restore when i call the restore function same database.
How can do this logic. in cakephp. when i restore the deleted record that we wan’t the it’s previous ID.
If any idea to build this logic Please suggest.

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

well , I am software engineer and working on project where i want add this functionality. So, I want to suggestion from experienced developer what i can do for soft-delete functionality. This question belongs to as logically implantation of system.

It depends on type of database and if SQL then it also depends on complexity of relationships between tables.

The easiest way would be NoSQL database where you would just have “Trash bin” collection where you will throw deleted documents with some context for restoring them back.

SQL database with complex relationship system… that would be a bit tougher piece of job. Definitely you should not move record to any other table, but just update it’s state to “deleted”, depending on complexity this will cascade into some “reorganization”, because corresponding child tables will not clean this for you, as if it would be a case with deleting.

Not an expert on SQL, but hope this will help at least a bit.

1 Like

woow thanks for sahtring

Thanks for sharing your suggestion. i am using PostgresSql, I know that it’s complex relationshitp make more complex so i need any new idea for implementation.