diff --git a/controller/hk_sql_utils.anubis b/controller/hk_sql_utils.anubis index 6de0419..d770e87 100644 --- a/controller/hk_sql_utils.anubis +++ b/controller/hk_sql_utils.anubis @@ -29,6 +29,23 @@ public define String } . +public define Maybe(One) + delete_from_ids + ( + SQLite3DataBase db, + String table_name, + List(Int) ids + )= + if sql_query_timeout(db, + "DELETE FROM "+table_name+ + " WHERE id IN ("+join(", ", to_List_String(ids))+");", + [], + "delete_from_ids") is + { + error(_) then failure, + ok(_, _, _) then success(unique) + }. + public define Int get_count_by_clause ( @@ -56,3 +73,23 @@ public define Int )= get_count_by_clause(db, table_name, "") . + + +public define List(Int) + get_ids_by_clause + ( + SQLite3DataBase db, + String table_name, + String clause + )= + with final_clause = if clause = "" then + "" + else + "WHERE "+clause, + + if sql_query_timeout(db, "SELECT \"id\" FROM "+table_name+" "+final_clause+";", [], "get_ids_by_clause") is + { + error(_) then [], + ok(_, cursor, _) then db_get_integer_list(cursor) + } +. -- libgit2 0.21.4