Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Using SQL ORMs with Node.js Performing CRUD Operations Delete a Record

dvir abuksis
dvir abuksis
14,608 Points

Problem with "Soft" Deletes

Hi, I got a problem with the "soft" delete, when I run my code (and even guil's code), the program actually deletes the row and not "soft" deleting it in the DB Browser. Does someone know why? Thanks.

Hello dvir abuksis ,

Did you by any chance put the timestamp in your movie.init() option back to true? If you don't this problem might arise because you don't have the data to the timestamp. Hope this helps :)

Make sure you're choosing 'Movie' table instead of 'Movies' in DB Browser

2 Answers

Had this problem as well. I had put timestamp: false, which caused this problem. Putting it back to true which allows for timestamps, did also allow for the soft delete to work properly as well, when I refreshed my DB.

If you are using visual studio code, while adding in the paranoid option, press Ctrl + Space. A hint window pops up and actually mentions timestamps must be true.

(property) ModelOptions<Movie>.paranoid?: boolean | undefined

Calling destroy will not delete the model, but instead set a deletedAt timestamp if this is true. Needs timestamps=true to work. Default false.