fn_delete.anubis
1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 19/03/2016
* Time: 17:27
* © Calexium
*/
read hayamiki_lib/types/hayamiki.anubis
read tools/basis.anubis
read tools/streams.anubis
read system/string.anubis
read fields.anubis
read columns.anubis
read html.anubis
public define Maybe(One)
generate_delete
(
Stream stream,
HK_Table table
)=
since table is hk_table(name, short_name, model, _),
since model is hk_model( columns, _),
with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
//generate the type of the table that contain all components
if write_string(stream,
"\n\n"+
//SQL query
"read tools/int.anubis\n\n"+
"public define Maybe(One)\n"+
" delete_"+name+"\n"+
" (\n"+
" SQLite3DataBase db,\n"+
" List(Int) ids\n"+
" )=\n"+
//DELETE SQL query
" if sql_query_timeout(db,\n"+
" \"DELETE FROM "+name+"\n"+
" WHERE id IN (\"+join(\", \", to_List_String(ids))+\");\",\n"+
" [],\n"+
" \"delete_"+name+"\") is\n"+
" {\n"+
" error(_) then failure,\n"+
" ok(_, _, _) then success(unique)\n"+
" }.\n\n"
// +
// "public define Maybe(One)\n"+
// " delete_"+name+"\n"+
// " (\n"+
// " SQLite3DataBase db,\n"+
// " List(Web_arg) lwa\n"+
// " )=\n"+
// " if extract_ids_from_web_arg(lwa) is\n"+
// " {\n"+
// " failure then failure,\n"+
// " success(ids) then success(delete_"+name+"(db, ids))\n"+
// " }.\n\n"
) is //end of the function
{
failure then println("can't write generate_update "+type_name); failure,
success(_) then success(unique)
}.