schema

package
v0.0.0-...-764bd47 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute interface {
	GetKey() string

	GetSelectDirect() ([]string, []interface{})

	GetOrderMap() map[string]string

	AvailableFilters() []interface{}
	ValidateFilters(map[string][]string) ([]Filter, error)
	GetFilterWhere(int, map[string][]string) ([]string, []interface{})

	DefaultFallback(interface{}, interface{}) (interface{}, error)
	Validate(interface{}) (interface{}, error)
	ValidateUpdate(interface{}, interface{}) (interface{}, error)

	GetInsert(interface{}) ([]string, []interface{})
}

type Authenticator

type Authenticator interface {
	GetUser(http.ResponseWriter, *http.Request, Context) (User, error)
}

type BaseFilter

type BaseFilter struct {
	QArgKey    string
	QArgValues []string
}

func (BaseFilter) GetQArgKey

func (bf BaseFilter) GetQArgKey() string

func (BaseFilter) GetQArgValues

func (bf BaseFilter) GetQArgValues() []string

type Context

type Context interface {
	GetServer() Server
	GetRequest() *http.Request
	WriteToResponse(blob interface{})

	SetUser(User)
	GetUser() User

	IncrementQueryCount()
	QueryRow(string, ...interface{}) *sql.Row
	Query(string, ...interface{}) (*sql.Rows, error)
	Exec(string, ...interface{}) (sql.Result, error)
	Begin() (Transaction, error)

	InitCache()
	FlushCache()
	CacheObject(Instance, map[string]map[string][]string)
	GetCachedObject(string, string) (Instance, map[string]map[string][]string)
	GetObjectsByIDs(*Model, []string, *Include) ([]Instance, []Instance, error)
	GetObjectsByIDsAllRelations(*Model, []string, *Include) ([]Instance, []Instance, error)
	GetObjectsByFilter(
		*Model,
		[]string,
		[]interface{},
		string,
		int,
		int,
		*Include,
	) (
		[]Instance,
		[]Instance,
		error,
	)

	CanAccessAllInstances([]Instance) bool
}

type Database

type Database interface {
	QueryRow(string, ...interface{}) *sql.Row
	Query(string, ...interface{}) (*sql.Rows, error)
	Exec(string, ...interface{}) (sql.Result, error)
	Begin() (*sql.Tx, error)
}

type ErrorSet

type ErrorSet struct {
	Errors []map[string]interface{} `json:"errors"`
}

func (ErrorSet) MarshalEasyJSON

func (v ErrorSet) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*ErrorSet) UnmarshalEasyJSON

func (v *ErrorSet) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Filter

type Filter interface {
	GetQArgKey() string
	GetQArgValues() []string

	GetWhere(Context, string, string, int) ([]string, []interface{})
}

type Include

type Include struct {
	Children map[string]*Include
}

func (*Include) AsString

func (i *Include) AsString() string

type Instance

type Instance interface {
	GetID() string
	SetID(string)
	GetType() string
	SetValues(values map[string]interface{})
	GetValues() map[string]interface{}
}

type InstancePointer

type InstancePointer struct {
	ID   *string `json:"id"`
	Type string  `json:"type"`
}

func AssertInstancePointer

func AssertInstancePointer(value interface{}) InstancePointer

func (InstancePointer) Equal

func (ip InstancePointer) Equal(oip InstancePointer) bool

func (*InstancePointer) GetID

func (ip *InstancePointer) GetID() string

func (*InstancePointer) GetType

func (ip *InstancePointer) GetType() string

func (InstancePointer) MarshalEasyJSON

func (v InstancePointer) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*InstancePointer) SetID

func (ip *InstancePointer) SetID(id string)

func (*InstancePointer) UnmarshalEasyJSON

func (v *InstancePointer) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Manager

type Manager interface {
	Create() Instance
	GetFilterForUser(User, int) ([]string, []interface{})

	BeforeCreate(Context, map[string]interface{}) error
	BeforeUpdate(Context, map[string]interface{}, map[string]interface{}) error
	BeforeSave(Context, map[string]interface{}) error
}

type ManagerStub

type ManagerStub struct {
}

func (ManagerStub) BeforeCreate

func (stub ManagerStub) BeforeCreate(c Context, values map[string]interface{}) error

func (ManagerStub) BeforeSave

func (stub ManagerStub) BeforeSave(c Context, values map[string]interface{}) error

func (ManagerStub) BeforeUpdate

func (stub ManagerStub) BeforeUpdate(
	c Context,
	oldValues map[string]interface{},
	newValues map[string]interface{},
) error

func (ManagerStub) GetFilterForUser

func (stub ManagerStub) GetFilterForUser(user User, nextArg int) ([]string, []interface{})

type Model

type Model struct {
	Type          string
	Table         string
	IDColumn      string
	IDGenerator   func(Context) string
	DefaultOrder  string
	Attributes    []Attribute
	Relationships []Relationship
	Manager       Manager
}

func (Model) DirectFields

func (m Model) DirectFields() ([]string, []interface{})

func (Model) ExtraFields

func (m Model) ExtraFields() ([]string, [][]interface{})

func (Model) GetOrderQuery

func (m Model) GetOrderQuery(asParam string) (string, string, error)

type Page

type Page struct {
	Provided bool `json:"-"`

	Metadata map[string]interface{} `json:"meta"`
	Links    map[string]*string     `json:"links"`
	Data     []interface{}          `json:"data"`
	Included *[]interface{}         `json:"included,omitempty"`
}

func (Page) IDs

func (p Page) IDs() []string

func (Page) MarshalEasyJSON

func (v Page) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Page) UnmarshalEasyJSON

func (v *Page) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Page) UnmarshalJSON

func (p *Page) UnmarshalJSON(data []byte) error

type Query

type Query struct {
	Query string
	Args  []interface{}
}

type Relationship

type Relationship interface {
	GetKey() string
	GetType() string

	GetSelectExtra() ([]string, []interface{})

	AvailableFilters() []interface{}
	ValidateFilters(map[string][]string) ([]Filter, error)
	GetFilterWhere(int, map[string][]string) ([]string, []interface{})

	GetDefaultValue() interface{}
	GetValues(
		Context,
		*Model,
		[]string,
		[][]interface{},
		int,
		int,
	) (
		map[string]interface{},
		map[string]map[string][]string,
	)

	GetInsert(interface{}) ([]string, []interface{})
	GetInsertQueries(string, interface{}) []Query
	GetUpdateQueries(string, interface{}, interface{}) []Query

	DefaultFallback(Context, interface{}, interface{}) (interface{}, error)
	Validate(Context, interface{}) (interface{}, error)
	ValidateUpdate(Context, interface{}, interface{}) (interface{}, error)
}

type Result

type Result struct {
	Provided bool `json:"-"`

	Links    map[string]*string `json:"links"`
	Data     interface{}        `json:"data"`
	Included *[]interface{}     `json:"included,omitempty"`
}

func (Result) MarshalEasyJSON

func (v Result) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Result) UnmarshalEasyJSON

func (v *Result) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Result) UnmarshalJSON

func (r *Result) UnmarshalJSON(data []byte) error

type Server

type Server interface {
	GetDatabase() Database

	GetDefaultDirectPageSize() int
	GetMaximumDirectPageSize() int
	GetIndirectPageSize() int

	GetModel(string) *Model
	GetRoute(string) string

	Whitespace() bool
	UseEasyJSON() bool
	LogSQL() bool

	Authenticate(http.ResponseWriter, *http.Request, Context) (User, error)
}

type Transaction

type Transaction interface {
	QueryRow(string, ...interface{}) *sql.Row
	Query(string, ...interface{}) (*sql.Rows, error)
	Exec(string, ...interface{}) (sql.Result, error)
	Commit() error
	Rollback() error
}

type User

type User interface {
}

Jump to

Keyboard shortcuts

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