23 lines
1.2 KiB
JSON
23 lines
1.2 KiB
JSON
{
|
|
"db_name": "PostgreSQL",
|
|
"query": "WITH RECURSIVE folder_hierarchy AS (\n -- Start with the given directory\n SELECT \n folder_id \n FROM \n folders \n WHERE \n folder_id = $1\n\n UNION ALL\n\n -- Recursively find all subdirectories\n SELECT \n f.folder_id\n FROM \n folders f\n INNER JOIN \n folder_hierarchy fh ON f.parent_folder_id = fh.folder_id\n),\ndeleted_files AS (\n -- Delete the files and return their IDs\n DELETE FROM \n files \n WHERE \n folder_id IN (SELECT folder_id FROM folder_hierarchy)\n RETURNING file_id\n),\ndeleted_folders AS (\n -- Delete the directories\n DELETE FROM \n folders \n WHERE \n folder_id IN (SELECT folder_id FROM folder_hierarchy)\n)\n-- Return the IDs of deleted files\nSELECT \n file_id \nFROM \n deleted_files;\n",
|
|
"describe": {
|
|
"columns": [
|
|
{
|
|
"ordinal": 0,
|
|
"name": "file_id",
|
|
"type_info": "Uuid"
|
|
}
|
|
],
|
|
"parameters": {
|
|
"Left": [
|
|
"Uuid"
|
|
]
|
|
},
|
|
"nullable": [
|
|
false
|
|
]
|
|
},
|
|
"hash": "13785c2084644fe5a0054c67c16e117dcbfae4f15cd09d364706394989739dc3"
|
|
}
|