This repository has been archived by the owner on Feb 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.go
49 lines (42 loc) · 2.2 KB
/
store.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package karigo
import "github.com/kkaribu/jsonapi"
// Store ...
type Store interface {
// Connection management
Open(driver, host, db, user, pw string, opts map[string]string) error
URL() string
Close()
// Transaction
Begin() (Tx, error)
// Resource manipulation
SelectCollection(tx Tx, resType string, from jsonapi.BelongsToFilter, params *jsonapi.Params, c jsonapi.Collection) error
SelectResource(tx Tx, resType, resID string, from jsonapi.BelongsToFilter, params *jsonapi.Params, r jsonapi.Resource) error
SelectInclusions(tx Tx, originType, originID string, from jsonapi.BelongsToFilter, params *jsonapi.Params) ([]jsonapi.Resource, error)
InsertResource(tx Tx, r jsonapi.Resource) error
UpdateResource(tx Tx, resType, resID string, updates map[string]interface{}) error
DeleteResource(tx Tx, resType, resID string) error
ResourceExists(tx Tx, resType, resID string) (bool, error)
// Relationship manipulation
SelectRelationship(tx Tx, resType, resID, relName string) (string, error)
SelectRelationships(tx Tx, resType, resID, relName string) ([]string, error)
UpdateRelationship(tx Tx, resType, resID, relName, relID string) error
UpdateRelationships(tx Tx, resType, resID, relName string, relIDs []string) error
InsertRelationships(tx Tx, resType, resID, relName string, relIDs []string) error
DeleteRelationship(tx Tx, resType, resID, relID, relName string) error
DeleteRelationships(tx Tx, resType, resID, relName string, relIDs []string) error
DeleteAllRelationships(tx Tx, resType, resID, relName string) error
// Other
CountCollectionSize(tx Tx, resType string, from jsonapi.BelongsToFilter, params *jsonapi.Params) (int, error)
// Database management
SetRegistry(reg *jsonapi.Registry)
SelectResourceTables(tx Tx) ([]string, error)
SelectRelationshipTables(tx Tx) ([]string, error)
SelectColumns(tx Tx, resType string) ([]map[string]string, error)
CreateResourceTable(tx Tx, typ jsonapi.Type) error
CreateRelationshipTable(tx Tx, rel jsonapi.Rel) error
AddColumn(tx Tx, resType string, attr jsonapi.Attr) error
DropTable(tx Tx, resType string) error
DropColumn(tx Tx, resType, colName string) error
DrainDatabase(tx Tx) error
SyncDatabase(tx Tx, reg *jsonapi.Registry, verbose, apply bool) error
}