db

package
v0.0.0-...-c896b06 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Content

type Content struct {
	// In DB.
	ContentID           string
	ContentParentTypeID string
	// We set.
	ContentValues []ContentValue
}

func (*Content) ID

func (c *Content) ID() string

func (*Content) MustValueByName

func (c *Content) MustValueByName(name string) (ret value.Value)

func (*Content) Type

func (c *Content) Type() string

func (*Content) ValueByName

func (c *Content) ValueByName(name string) (value.Value, bool)

func (*Content) Values

func (c *Content) Values() []value.Value

type ContentList

type ContentList struct {
	ContentList       []content.Content
	ContentListMore   bool
	ContentListBefore int
}

func (*ContentList) Before

func (cl *ContentList) Before() int

func (*ContentList) List

func (cl *ContentList) List() []content.Content

func (*ContentList) More

func (cl *ContentList) More() bool

type ContentNewParam

type ContentNewParam struct {
	Type  string
	Name  string
	Value string
}

type ContentRefSet

type ContentRefSet struct {
	ContentTypeID, ContentID string
}

type ContentType

type ContentType struct {
	ContentTypeID     string
	ContentTypeName   string
	ContentTypeFields []ContentTypeField
}

func (*ContentType) Fields

func (ct *ContentType) Fields() []valuetype.ValueType

func (*ContentType) FieldsWithRefCount

func (ct *ContentType) FieldsWithRefCount() (count int)

func (*ContentType) ID

func (ct *ContentType) ID() string

func (*ContentType) Name

func (ct *ContentType) Name() string

type ContentTypeField

type ContentTypeField struct {
	FieldID   string
	FieldName string
	FieldType string
}

func (*ContentTypeField) ID

func (f *ContentTypeField) ID() string

func (*ContentTypeField) Name

func (f *ContentTypeField) Name() string

func (*ContentTypeField) Type

func (f *ContentTypeField) Type() string

type ContentTypeList

type ContentTypeList struct {
	ContentTypeList       []contenttype.ContentType
	ContentTypeListMore   bool
	ContentTypeListBefore int
}

func (*ContentTypeList) Before

func (ctl *ContentTypeList) Before() int

func (*ContentTypeList) List

func (ctl *ContentTypeList) List() []contenttype.ContentType

func (*ContentTypeList) More

func (ctl *ContentTypeList) More() bool

type ContentTypeNewParam

type ContentTypeNewParam struct {
	Name, Type string
}

type ContentTypeUpdateParam

type ContentTypeUpdateParam struct {
	ID, Name, Type string
}

type ContentUpdateParam

type ContentUpdateParam struct {
	ID    string
	Type  string
	Value string
}

type ContentValue

type ContentValue struct {
	FieldID            string
	FieldType          string            // StringSmall
	FieldName          string            // Title of a blog post
	FieldValue         string            // "My First Blog Post!"
	FieldReference     content.Content   `json:",omitempty"`
	FieldReferenceList []content.Content `json:",omitempty"`
}

func (*ContentValue) ID

func (c *ContentValue) ID() string

func (*ContentValue) MarshalJSON

func (c *ContentValue) MarshalJSON() (ret []byte, err error)

func (*ContentValue) Name

func (c *ContentValue) Name() string

func (*ContentValue) RefID

func (c *ContentValue) RefID() string

func (*ContentValue) RefListIDs

func (c *ContentValue) RefListIDs() []string

func (*ContentValue) RefListNames

func (c *ContentValue) RefListNames() string

func (*ContentValue) RefName

func (c *ContentValue) RefName() string

func (*ContentValue) Type

func (c *ContentValue) Type() string

func (*ContentValue) UnmarshalJSON

func (c *ContentValue) UnmarshalJSON(b []byte) error

func (*ContentValue) Value

func (c *ContentValue) Value() string

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

func New

func New(log *log.Logger, typ, creds string, sec securer) (*DB, error)

New, does as one might expect, given a logger, type of database, database connection string, and securer interface, opens a pool'd connection to a mysql database and pings. If ping fails we return error and nil *DB.

func NewWithConn

func NewWithConn(log *log.Logger, sec securer, conn *sql.DB) (*DB, error)

NewWithConn creates a *DB type and pings the MySQL server. If ping fails we return error.

func (*DB) ContentDelete

func (db *DB) ContentDelete(space space.Space, ct contenttype.ContentType, content content.Content) error

func (*DB) ContentGet

func (db *DB) ContentGet(space space.Space, ct contenttype.ContentType, contentID string) (content.Content, error)

func (*DB) ContentIter

func (db *DB) ContentIter(space space.Space, ct contenttype.ContentType, sortField string) (*contentIter, *sql.Tx, error)

func (*DB) ContentNew

func (db *DB) ContentNew(space space.Space, ct contenttype.ContentType, params []ContentNewParam) (content.Content, error)

func (*DB) ContentPerContentType

func (db *DB) ContentPerContentType(space space.Space, ct contenttype.ContentType, before int, order OrderType, sortField string) (content.ContentList, error)

func (*DB) ContentRefererList

func (db *DB) ContentRefererList(contentID string) (ret []ContentRefSet, err error)

ContentRefererList will retreive all content IDs that references a given piece of content.

func (*DB) ContentSearch

func (db *DB) ContentSearch(space space.Space, ct contenttype.ContentType, sortField, query string, before int) (content.ContentList, error)

func (*DB) ContentTypeDelete

func (db *DB) ContentTypeDelete(space space.Space, ct contenttype.ContentType) error

func (*DB) ContentTypeGet

func (db *DB) ContentTypeGet(space space.Space, contenttypeID string) (contenttype.ContentType, error)

func (*DB) ContentTypeIter

func (db *DB) ContentTypeIter(t *sql.Tx, space space.Space) *contentTypeIter

func (*DB) ContentTypeNew

func (db *DB) ContentTypeNew(space space.Space, name string, params []ContentTypeNewParam) (contenttype.ContentType, error)

func (*DB) ContentTypeSearch

func (db *DB) ContentTypeSearch(space space.Space, query string, before int) (contenttype.ContentTypeList, error)

TODO: Consolidate with other list function here. They are the same except for the query used.

func (*DB) ContentTypeUpdate

func (db *DB) ContentTypeUpdate(space space.Space, contenttype contenttype.ContentType, name string, newParams []ContentTypeNewParam, updateParams []ContentTypeUpdateParam) (contenttype.ContentType, error)

ContentTypeUpdate will either remove fields are add fields to a contenttype. Note: field types cannot be changed (e.g. if a field is of type InputHTML it cannot become a StringSmall. Field type names can be changed.

func (*DB) ContentTypesPerSpace

func (db *DB) ContentTypesPerSpace(space space.Space, before int) (contenttype.ContentTypeList, error)

func (*DB) ContentUpdate

func (db *DB) ContentUpdate(space space.Space, ct contenttype.ContentType, content content.Content, newParams []ContentNewParam, updateParams []ContentUpdateParam) (content.Content, error)

func (*DB) EnsureSetup

func (db *DB) EnsureSetup() error

Ensure we have the tables we require. If we receive an error other than "table already exists" and also "duplicate entry" for built in data types that error will be returned. Mainly, we are runnin CREATE TABLE and some INSERT INTO of predefined value types.

func (*DB) FileExists

func (db *DB) FileExists(URL string) (bool, error)

FileExists makes sure SOME space and content owns the file. I.E. deleted spaces can't server files.

func (*DB) HookDelete

func (db *DB) HookDelete(s space.Space, h hook.Hook) error

func (*DB) HookGet

func (db *DB) HookGet(space space.Space, id string) (hook.Hook, error)

func (*DB) HookIter

func (db *DB) HookIter(t *sql.Tx, space space.Space) *hookIter

func (*DB) HookNew

func (db *DB) HookNew(space space.Space, url string) (hook.Hook, error)

func (*DB) HooksPerSpace

func (db *DB) HooksPerSpace(space space.Space, before int) (hook.HookList, error)

func (*DB) SpaceCopy

func (db *DB) SpaceCopy(user user.User, prevS space.Space, name, desc string) (space.Space, error)

func (*DB) SpaceDelete

func (db *DB) SpaceDelete(user user.User, space space.Space) error

func (*DB) SpaceGet

func (db *DB) SpaceGet(user user.User, spaceID string) (space.Space, error)

func (*DB) SpaceNew

func (db *DB) SpaceNew(user user.User, name, desc string) (space.Space, error)

func (*DB) SpaceUpdate

func (db *DB) SpaceUpdate(user user.User, space space.Space, name, desc string) (space.Space, error)

func (*DB) SpacesPerUser

func (db *DB) SpacesPerUser(user user.User, before int) (space.SpaceList, error)

func (*DB) UserGet

func (db *DB) UserGet(username, password string) (user.User, error)

func (*DB) UserGetFromToken

func (db *DB) UserGetFromToken(token string) (user.User, error)

func (*DB) UserNew

func (db *DB) UserNew(username, password, verifyPassword string) (user.User, error)

type Hook

type Hook struct {
	// contains filtered or unexported fields
}

func (*Hook) ID

func (h *Hook) ID() string

func (*Hook) URL

func (h *Hook) URL() string

type HookList

type HookList struct {
	HookList       []hook.Hook
	HookListMore   bool
	HookListBefore int
}

func (*HookList) Before

func (hl *HookList) Before() int

func (*HookList) List

func (hl *HookList) List() []hook.Hook

func (*HookList) More

func (hl *HookList) More() bool

type OrderType

type OrderType struct {
	// contains filtered or unexported fields
}

iota doesn't quite pass the compile time checks I want.

var (
	OrderAsc  OrderType = OrderType{/* contains filtered or unexported fields */}
	OrderDesc OrderType = OrderType{/* contains filtered or unexported fields */}
)

type Space

type Space struct {
	SpaceID   string
	SpaceName string
	SpaceDesc string
}

func (*Space) Desc

func (s *Space) Desc() string

func (*Space) ID

func (s *Space) ID() string

func (*Space) Name

func (s *Space) Name() string

type SpaceList

type SpaceList struct {
	SpaceList       []space.Space
	SpaceListMore   bool
	SpaceListBefore int
}

func (*SpaceList) Before

func (sl *SpaceList) Before() int

func (*SpaceList) List

func (sl *SpaceList) List() []space.Space

func (*SpaceList) More

func (sl *SpaceList) More() bool

type User

type User struct {
	// Stored in DB.
	UserID   string
	UserName string
	// contains filtered or unexported fields
}

func (*User) ID

func (u *User) ID() string

func (*User) Name

func (u *User) Name() string

func (*User) Token

func (u *User) Token() string

Jump to

Keyboard shortcuts

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