-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.go
31 lines (23 loc) · 1.12 KB
/
storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package crudgolab // import "gopkg.in/kravchadev/crudgolab.v1"
import (
"encoding/json"
"net/url"
)
type StorageStatusResponse interface {
Error() string // ошибки
StatusCode() int // коды статусов http
}
type Storage interface {
// создает ресурс и сохраняет в нем данные, затем возвращает идентификатор
Create(collection string, body *json.Decoder, query url.Values) (string, StorageStatusResponse)
// читаем ресурс по ид
Get(collection, id string, query url.Values) (interface{}, StorageStatusResponse)
// читае все ресурсы в указанной коллекции
GetAll(collection string, query url.Values) ([]interface{}, StorageStatusResponse)
// обновить ресурс
Update(collection, id string, body *json.Decoder, query url.Values) StorageStatusResponse
// удалить ресурс
Delete(collection, id string, query url.Values) StorageStatusResponse
// удалить все ресурсы в коллекции
DeleteAll(collection string, query url.Values) StorageStatusResponse
}