diff --git a/database/db_types.anubis b/database/db_types.anubis index 7c7cd37..0e1276b 100644 --- a/database/db_types.anubis +++ b/database/db_types.anubis @@ -77,8 +77,29 @@ public define DB_id else db_id(value) . - - + +/** + * produce path from db_id to optimize fs access and never have more than 100 folders + */ +public define String + to_fs_folder + ( + DB_id idx + )= + if idx is + { + none then "none/", + db_id(_idx) then + with idx_str = abs_to_decimal(_idx), + //if the idx value is less than 10, we add 0 as prefix of that idx. i.e. if the idx is 3 the final_idx_str will be 03 which will be cut as 0/3/. + //the idx < 10 will be located in the 0 folder. + with final_idx_str= if _idx < 10 then "0"+idx_str else idx_str, + with result_path = join("/", reverse(map_select((Bool first, Word8 char) |-> if first then (false, failure) else (false, success(implode([char]))), true, reverse(explode(final_idx_str)))) + [idx_str])+"/", + println("to_fs_folder result_path "+result_path); + result_path + } +. + public define String to_String ( -- libgit2 0.21.4