db

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortPagesByUpdatedAt

func SortPagesByUpdatedAt(data []*models.Page, ascending bool)

func SortRoutesByPath added in v0.2.0

func SortRoutesByPath(data []*models.Route) []*models.Route

Types

type AddressableProto

type AddressableProto interface {
	GetUuid() string
	proto.Message
}

type Backend

type Backend interface {
	// GetUser looks up a user by uuid, and returns nil, nil if no user.
	GetUser(uuid string) (*models.User, error)

	// GetUserByEmail TODO
	GetUserByEmail(email string) (*models.User, error)

	// GetUserByToken looks up a user by token, and returns nil, nil if no user.
	GetUserByToken(token string) (*models.User, error)

	// UpdateUser
	UpdateUser(*models.User) error

	// ListUsers lists all the existing users. May be unsorted.
	ListUsers() ([]*models.User, error)

	// GetPage looks up a page by uuid, and returns nil, nil if no page.
	GetPage(uuid string) (*models.Page, error)

	// UpdatePage updates (creating if necessary) a new page.
	// New pages and new content blocks will be assigned UUIDs
	UpdatePage(*models.Page) error

	// DeletePage deletes the page and should also delete
	// related routes.
	DeletePage(*models.Page) error

	// ListPages lists all the existing pages. May be unsorted.
	ListPages(*api.ListPageRequest) ([]*models.Page, error)

	// GetRoute fetches a route from the DB by UUID
	GetRoute(uuid string) (*models.Route, error)

	// UpdateRoute updates (or creates if necessary) an existing route.
	// The route uuid is set if it is blank.
	UpdateRoute(*models.Route) error

	// DeleteRoute deletes a route from the DB (but not any related pages).
	DeleteRoute(*models.Route) error

	// ListRoutes returns all existing routes. May be unsorted.
	ListRoutes(*api.ListRouteRequest) ([]*models.Route, error)

	GetData(key string) (*models.Data, error)

	UpdateData(*models.Data) error

	UpdateDataBatch([]*models.Data) error

	DeleteData(*models.Data) error

	ListData() ([]*models.Data, error)

	GetFile(uuid string) (*models.File, error)

	GetFileByName(name string) (*models.File, error)

	UpdateFile(*models.File) error

	DeleteFile(*models.File) error

	ListFiles() ([]*models.File, error)

	Debug(w io.Writer) error // print debug info
}

Backend interface for models. todo: split update/create? todo: filter page list? for SQL dbs, how to determine if we need to upgrade database/run migration? https://github.com/mgutz/dat

type Module

type Module struct {
	Backend
}

func (*Module) Export

func (m *Module) Export() (*export.Export, error)

Export generates a dump of routes and routes

func (*Module) ExportToJSON added in v0.3.0

func (m *Module) ExportToJSON(path string) error

func (*Module) Import

func (m *Module) Import(export *export.Export) error

Import pages and routes from an Export object.

func (*Module) Init

func (m *Module) Init(c *service.Config)

func (*Module) Register

func (m *Module) Register(b Backend) error

type TimestampedProto

type TimestampedProto interface {
	GetTimestamps() *models.Timestamp
	SetTimestamps(*models.Timestamp)
	proto.Message
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL