storageDao.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package dao
  2. import (
  3. "io"
  4. "wkla.no-ip.biz/gogs/Willie/MsgService/MessageService/model"
  5. )
  6. //FulltextIndexName name of the index containing fulltext data
  7. const FulltextIndexName = "$fulltext"
  8. /*
  9. StorageDao this is the interface which all method implementation of a storage engine has to fulfill
  10. */
  11. type StorageDao interface {
  12. ProcessFiles(RemoveCallback func(file model.FileInfo) bool) error
  13. AddFile(backend string, filename string, reader io.Reader) (string, error)
  14. GetFilename(backend string, fileid string) (string, error)
  15. GetFile(backend string, fileid string, stream io.Writer) error
  16. DeleteFile(backend string, fileid string) error
  17. CreateModel(route model.Route, data model.JSONMap) (string, error)
  18. CreateModels(route model.Route, datas []model.JSONMap) ([]string, error)
  19. CountModel(route model.Route) (int, error)
  20. GetModel(route model.Route) (model.JSONMap, error)
  21. QueryModel(route model.Route, query string, offset int, limit int) (int, []model.JSONMap, error)
  22. UpdateModel(route model.Route, data model.JSONMap) (model.JSONMap, error)
  23. DeleteModel(route model.Route) error
  24. GetIndexNames(route model.Route) ([]string, error)
  25. DeleteIndex(route model.Route, name string) error
  26. UpdateIndex(route model.Route, index model.Index) error
  27. GetUsers() ([]model.User, error)
  28. GetUser(username string) (model.User, bool)
  29. AddUser(user model.User) (model.User, error)
  30. DeleteUser(username string) error
  31. ChangePWD(username string, newpassword string) (model.User, error)
  32. DeleteBackend(beackend string) error
  33. DropAll()
  34. Ping() error
  35. Stop()
  36. }
  37. var storageDao StorageDao
  38. //GetStorage getting the actual storage dao
  39. func GetStorage() StorageDao {
  40. return storageDao
  41. }
  42. //SetStorage setting the actual storage dad
  43. func SetStorage(storage StorageDao) {
  44. storageDao = storage
  45. }