From b770c5c9d81b30d9d3c2c578251509f4322cf1b7 Mon Sep 17 00:00:00 2001 From: totoro Date: Tue, 20 Mar 2018 14:40:13 +0100 Subject: [PATCH] add converter from - DB_id -> Maybe(Int) - String -> Maybe(DB_id) - Maybe(String) -> Maybe(DB_id) --- database/db_types.anubis | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+), 0 deletions(-) diff --git a/database/db_types.anubis b/database/db_types.anubis index 0b63b21..e99d9f8 100644 --- a/database/db_types.anubis +++ b/database/db_types.anubis @@ -5,6 +5,7 @@ * Time: 22:41 * */ +transmit system/convert.anubis transmit tools/basis.anubis transmit tools/ISO-8601.anubis @@ -35,6 +36,17 @@ public define String db_id(_idx) then abs_to_decimal(_idx) }. +public define Maybe(Int) + to_mb_Int + ( + DB_id idx + )= + if idx is + { + none then failure, + db_id(_idx) then success(_idx) + }. + public define JsonValue to_JsonValue ( @@ -90,6 +102,32 @@ public define DB_id db_id(value) . +public define Maybe(DB_id) + to_mb_DB_id + ( + String db_id_str + )= + if decimal_scan(db_id_str) is + { + failure then failure, + success(db_id_int) then success(to_DB_id(db_id_int)) + } +. + +public define Maybe(DB_id) + to_mb_DB_id + ( + Maybe(String) mb_db_id_str + )= + if mb_db_id_str is + { + failure then failure, + success(db_id_str) then to_mb_DB_id(db_id_str) + } +. + + + /** * produce path from db_id to optimize fs access and never have more than 100 folders */ -- libgit2 0.21.4