You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
730 B

require "option_parser"
require "uuid"
require "uuid/json"
require "ipc"
require "authd"
require "dodb"
require "./todod.cr"
class TodoD::Storage
getter root : String
getter lists : DODB::DataBase(List)
getter lists_by_id : DODB::Index(List)
getter lists_per_user : DODB::Tags(List)
getter tasks : DODB::DataBase(Task)
getter tasks_by_id : DODB::Index(Task)
def initialize(@root)
@lists = DODB::DataBase(List).new("#{@root}/lists")
@lists_per_user = @lists.new_tags "user", &.users_with_read_permissions.map(&.to_s)
@lists_by_id = @lists.new_index "id", &.id
@tasks = DODB::DataBase(Task).new("#{@root}/tasks")
@tasks_by_id = @tasks.new_index "id", &.id
end
def new_list(list)
@lists << list
end
end