anchor.diff:              Design == DesignName, DbName2 == DbName]
       } || #view_info{db_name = DbName1, design = DesignName} <- ?VIEW_LIST, DbName1 == DbName]
   } || DbName <- ?DB_LIST]).
  -
   -endif.
positive.code: -define(EXPIRED_FUSE_SESSIONS_VIEW, #view_info{name = "expired_fuse_sessions", design = ?FUSE_SESSIONS_DESIGN_NAME, db_name = ?SYSTEM_DB_NAME}).
  -define(FUSE_SESSIONS_BY_USER_ID_VIEW, #view_info{name = "fuse_sessions_by_user_id", design = ?FUSE_SESSIONS_DESIGN_NAME, db_name = ?SYSTEM_DB_NAME}).
  
  %% List of all used databases :: [string()]
  -define(DB_LIST, [?SYSTEM_DB_NAME, ?FILES_DB_NAME, ?DESCRIPTORS_DB_NAME, ?USERS_DB_NAME]).
  %% List of all used views :: [#view_info]
  -define(VIEW_LIST, [?FILE_TREE_VIEW, ?WAITING_FILES_TREE_VIEW, ?FILE_SUBDIRS_VIEW, ?FD_BY_FILE_VIEW, ?FD_BY_EXPIRED_BEFORE_VIEW, ?ALL_STORAGE_VIEW,
      ?FILES_BY_UID_AND_FILENAME, ?FILE_META_BY_TIMES, ?FILES_BY_META_DOC,
      ?USER_BY_EMAIL_VIEW, ?USER_BY_LOGIN_VIEW, ?USER_BY_DN_VIEW, ?USER_BY_UID_VIEW, ?STORAGE_BY_ID_VIEW,
      ?SHARE_BY_FILE_VIEW, ?SHARE_BY_USER_VIEW, ?USER_FILES_NUMBER_VIEW, ?USER_FILES_SIZE_VIEW, ?GROUP_FILES_NUMBER_VIEW,
      ?FUSE_CONNECTIONS_VIEW, ?EXPIRED_FUSE_SESSIONS_VIEW, ?FUSE_SESSIONS_BY_USER_ID_VIEW]).
  %% Default database name
  -define(DEFAULT_DB, lists:nth(1, ?DB_LIST)).
  
  %% Do not try to read this macro (3 nested list comprehensions). All it does is:
  %% Create an list containing #db_info structures base on ?DB_LIST
  %% Inside every #db_info, list of #design_info is created based on views list (?VIEW_LIST)
  %% Inside every #design_info, list of #view_info is created based on views list (?VIEW_LIST)
  %% Such structural representation of views, makes it easier to initialize views in DBMS
  %% WARNING: Do not evaluate this macro anywhere but dao_worker:init/cleanup because it's
  %% potentially slow - O(db_count * view_count^2)
  -define(DATABASE_DESIGN_STRUCTURE, [#db_info{name = DbName,
      designs = [#design_info{name = DesignName,
  
negative.code:     %next_record        -> ?record_info_gen(next_record);
          _ -> {error, unsupported_record}
      end).
  
  
  %% Record-wrapper for regular records that needs to be saved in DB. Adds UUID and Revision info to each record.
  %% `uuid` is document UUID, `rev_info` is documents' current revision number
  %% `record` is an record representing this document (its data), `force_update` is a flag
  %% that forces dao:save_record/1 to update this document even if rev_info isn't valid or up to date.
  -record(veil_document, {uuid = "", rev_info = 0, record = none, force_update = false}).
  
  %% Those records represent view result Each #view_resault contains list of #view_row.
  %% If the view has been queried with `include_docs` option, #view_row.doc will contain #veil_document, therefore
  %% #view_row.id == #view_row.doc#veil_document.uuid. Unfortunately wrapping demanded record in #veil_document is
  %% necessary because we may need revision info for that document.
  -record(view_row, {id = "", key = "", value = 0, doc = none}).
  -record(view_result, {total = 0, offset = 0, rows = []}).
  
  %% These records allows representing databases, design documents and their views.
  %% Used in DAO initial configuration in order to easily setup/update views in database.
  -record(db_info, {name = "", designs = []}).
  -record(design_info, {name = "", version = 0, views = []}).
  -record(view_info, {name = "", design = "", db_name = ""}).
  
  %% ====================================================================
  %% DB definitions
  