api.hrl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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(Backend :: atom(), Module :: atom()) -> list(#table{}).
  10. % meta info
  11. -spec modules() -> list(atom()).
  12. -spec containers() -> list(tuple(atom(),list(atom()))).
  13. -spec tables() -> list(#table{}).
  14. -spec table(Tab :: atom()) -> #table{}.
  15. -spec version() -> {version,string()}.
  16. % chain ops
  17. -spec create(Container :: atom()) -> integer().
  18. -spec add(Record :: tuple()) -> {ok,tuple()} | {error,exist} | {error,no_container}.
  19. -spec remove(Record :: tuple()) -> ok | {error,any()}.
  20. -spec remove(Tab :: atom(), Key :: any()) -> ok | {error,any()}.
  21. % raw ops
  22. -spec put(Record :: tuple()) -> ok | {error,any()}.
  23. -spec delete(Tab :: atom(), Key :: any()) -> ok | {error,any()}.
  24. % read ops
  25. -spec get(Tab :: atom(), Key :: any()) -> {ok,any()} | {error,duplicated} | {error,not_found}.
  26. -spec get(Tab :: atom(), Key :: any(), Value :: any()) -> {ok,any()}.
  27. -spec index(Tab :: atom(), Key :: any(), Value :: any()) -> list(tuple()).
  28. % import/export
  29. -spec load_db(Path :: string()) -> list(ok | {error,any()}).
  30. -spec save_db(Path :: string()) -> ok | {error,any()}.