db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2017 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)

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

	// 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() ([]*models.Route, 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) Import

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

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