Task F: Account Deletion

When a user decides to delete her account, we need to delete all the user-related information from the database, as well as all the user’s files.

Implementing Account-Deletion Service Operations

The first thing to do is to write the queries to delete the user along with the files associated with them. Add the following code to the queries.sql file:

 -- :name delete-user! :! :n
 -- deletes the user account
 DELETE​ ​FROM​ users
 WHERE​ id = :id
 -- :name delete-user-images! :! :n
 -- deletes all the images for the specified user
 DELETE​ ​FROM​ files
 WHERE​ ​owner​ = :​owner

Since account deletion is a single operation, these queries have to be run atomically, ...

Get Web Development with Clojure, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.