fn_delete.anubis 1.9 KB
/*
 * 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, constraints, _),
  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)
  }.