api.hrl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. -include("metainfo.hrl").
  2. % service
  3. -spec start() -> ok | {error,any()}.
  4. -spec stop() -> stopped.
  5. % schema change
  6. -spec destroy() -> ok.
  7. -spec join() -> ok | {error,any()}.
  8. -spec join(Node :: string()) -> [{atom(),any()}].
  9. -spec init_db() -> list(tuple(list(), skip | ok)).
  10. -spec init(Backend :: atom(), Module :: atom()) -> list(#table{}).
  11. % meta info
  12. -spec modules() -> list(atom()).
  13. -spec containers() -> list(tuple(atom(),list(atom()))).
  14. -spec tables() -> list(#table{}).
  15. -spec table(Tab :: atom()) -> #table{}.
  16. -spec version() -> {version,string()}.
  17. % chain ops
  18. -spec create(Container :: atom()) -> integer().
  19. -spec add(Record :: tuple()) -> {ok,tuple()} | {error,exist} | {error,no_container}.
  20. -spec remove(Record :: tuple()) -> ok | {error,any()}.
  21. -spec remove(Tab :: atom(), Key :: any()) -> ok | {error,any()}.
  22. % raw ops
  23. -spec put(Record :: tuple()) -> ok | {error,any()}.
  24. -spec delete(Tab :: atom(), Key :: any()) -> ok | {error,any()}.
  25. % read ops
  26. -spec get(Tab :: atom(), Key :: any()) -> {ok,any()} | {error,duplicated} | {error,not_found}.
  27. -spec get(Tab :: atom(), Key :: any(), Value :: any()) -> {ok,any()}.
  28. -spec index(Tab :: atom(), Key :: any(), Value :: any()) -> list(tuple()).
  29. % import/export
  30. -spec load_db(Path :: string()) -> list(ok | {error,any()}).
  31. -spec save_db(Path :: string()) -> ok | {error,any()}.