todod/altsrc/main.cr

29 lines
551 B
Crystal
Raw Normal View History

2019-12-12 06:26:17 +01:00
require "option_parser"
require "uuid"
require "uuid/json"
2019-12-13 05:47:45 +01:00
require "dodb"
2019-12-12 06:26:17 +01:00
class TodoD::Storage
getter root : String
2019-12-13 05:47:45 +01:00
getter lists : DODB::DataBase(String, List)
getter tasks : DODB::DataBase(String, Task)
getter lists_per_user : DODB::Tags(List)
2019-12-12 06:26:17 +01:00
def initialize(@root)
2019-12-13 05:47:45 +01:00
@lists = DODB::DataBase(String, List).new("#{@root}/lists")
@lists_per_user = @lists.new_tags "user", &.users_with_read_permissions.map(&.to_s)
2019-12-12 06:26:17 +01:00
2019-12-13 05:47:45 +01:00
@tasks = DODB::DataBase(String, Task).new("#{@root}/tasks")
2019-12-12 06:26:17 +01:00
end
def new_list(list)
@lists[list.id] = list
end
end