Abstracting more the store concept
This commit is contained in:
parent
19ab85b329
commit
55e49bea51
5 changed files with 24 additions and 5 deletions
3
Makefile
3
Makefile
|
@ -14,6 +14,9 @@ packdev:
|
||||||
go:
|
go:
|
||||||
go build -o $(GOBIN) $(GOMAIN)
|
go build -o $(GOBIN) $(GOMAIN)
|
||||||
|
|
||||||
|
watch-server:
|
||||||
|
cd server; modd
|
||||||
|
|
||||||
goUbuntu:
|
goUbuntu:
|
||||||
env GOOS=linux GOARCH=amd64 go build -o $(GOBIN) $(GOMAIN)
|
env GOOS=linux GOARCH=amd64 go build -o $(GOBIN) $(GOMAIN)
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,11 @@ import (
|
||||||
|
|
||||||
type App struct {
|
type App struct {
|
||||||
config *config.Configuration
|
config *config.Configuration
|
||||||
store *store.SQLStore
|
store store.Store
|
||||||
wsServer *ws.WSServer
|
wsServer *ws.WSServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config *config.Configuration, store *store.SQLStore, wsServer *ws.WSServer) *App {
|
func New(config *config.Configuration, store store.Store, wsServer *ws.WSServer) *App {
|
||||||
return &App{config: config, store: store, wsServer: wsServer}
|
return &App{config: config, store: store, wsServer: wsServer}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/mattermost/mattermost-octo-tasks/server/app"
|
"github.com/mattermost/mattermost-octo-tasks/server/app"
|
||||||
"github.com/mattermost/mattermost-octo-tasks/server/services/config"
|
"github.com/mattermost/mattermost-octo-tasks/server/services/config"
|
||||||
"github.com/mattermost/mattermost-octo-tasks/server/services/store"
|
"github.com/mattermost/mattermost-octo-tasks/server/services/store"
|
||||||
|
"github.com/mattermost/mattermost-octo-tasks/server/services/store/sqlstore"
|
||||||
"github.com/mattermost/mattermost-octo-tasks/server/web"
|
"github.com/mattermost/mattermost-octo-tasks/server/web"
|
||||||
"github.com/mattermost/mattermost-octo-tasks/server/ws"
|
"github.com/mattermost/mattermost-octo-tasks/server/ws"
|
||||||
)
|
)
|
||||||
|
@ -17,11 +18,11 @@ type Server struct {
|
||||||
config *config.Configuration
|
config *config.Configuration
|
||||||
wsServer *ws.WSServer
|
wsServer *ws.WSServer
|
||||||
webServer *web.WebServer
|
webServer *web.WebServer
|
||||||
store *store.SQLStore
|
store store.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config *config.Configuration) (*Server, error) {
|
func New(config *config.Configuration) (*Server, error) {
|
||||||
store, err := store.NewSQLStore(config.DBType, config.DBConfigString)
|
store, err := sqlstore.NewSQLStore(config.DBType, config.DBConfigString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Unable to start the database", err)
|
log.Fatal("Unable to start the database", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package store
|
package sqlstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
15
server/services/store/store.go
Normal file
15
server/services/store/store.go
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package store
|
||||||
|
|
||||||
|
import "github.com/mattermost/mattermost-octo-tasks/server/model"
|
||||||
|
|
||||||
|
// Store represents the abstraction of the data storage
|
||||||
|
type Store interface {
|
||||||
|
GetBlocksWithParentAndType(parentID string, blockType string) ([]model.Block, error)
|
||||||
|
GetBlocksWithParent(parentID string) ([]model.Block, error)
|
||||||
|
GetBlocksWithType(blockType string) ([]model.Block, error)
|
||||||
|
GetSubTree(blockID string) ([]model.Block, error)
|
||||||
|
GetAllBlocks() ([]model.Block, error)
|
||||||
|
GetParentID(blockID string) (string, error)
|
||||||
|
InsertBlock(block model.Block) error
|
||||||
|
DeleteBlock(blockID string) error
|
||||||
|
}
|
Loading…
Reference in a new issue