internal

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IdFieldColumn      = "id"
	IdFieldJsonapiName = "id"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JargoTag added in v0.0.2

type JargoTag struct {
	Name    string
	Options map[string]string
}

type Schema

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

func (*Schema) CreateRealtimeTriggers

func (s *Schema) CreateRealtimeTriggers(db *pg.DB, functionName string) error

func (*Schema) CreateTable

func (s *Schema) CreateTable(db *pg.DB) error

CreateTable creates the database table for this Schema if it doesn't exist yet.

func (*Schema) Fields

func (s *Schema) Fields() []SchemaField

Fields returns all of Schema's fields.

func (*Schema) IdField added in v0.0.2

func (s *Schema) IdField() SchemaField

IdField returns the Schema's id field.

func (*Schema) IsJsonapiModelCollection

func (s *Schema) IsJsonapiModelCollection(data interface{}) bool

func (*Schema) IsPGModelCollection

func (s *Schema) IsPGModelCollection(data interface{}) bool

func (*Schema) IsResourceModelCollection

func (s *Schema) IsResourceModelCollection(data interface{}) bool

func (*Schema) JSONAPIName

func (s *Schema) JSONAPIName() string

func (*Schema) NewJsonapiModelInstance

func (s *Schema) NewJsonapiModelInstance() interface{}

func (*Schema) NewPGModelCollection

func (s *Schema) NewPGModelCollection(entries ...interface{}) interface{}

func (*Schema) NewPGModelInstance

func (s *Schema) NewPGModelInstance() interface{}

func (*Schema) NewResourceModelCollection

func (s *Schema) NewResourceModelCollection(entries ...interface{}) interface{}

func (*Schema) NewResourceModelInstance

func (s *Schema) NewResourceModelInstance() interface{}

func (*Schema) ParseJsonapiModel

func (s *Schema) ParseJsonapiModel(instance interface{}) *SchemaInstance

func (*Schema) ParseJsonapiModelCollection

func (s *Schema) ParseJsonapiModelCollection(instance interface{}) []*SchemaInstance

func (*Schema) ParsePGModel

func (s *Schema) ParsePGModel(instance interface{}) *SchemaInstance

func (*Schema) ParsePGModelCollection

func (s *Schema) ParsePGModelCollection(instance interface{}) []*SchemaInstance

func (*Schema) ParseResourceModel

func (s *Schema) ParseResourceModel(instance interface{}) *SchemaInstance

func (*Schema) ParseResourceModelCollection

func (s *Schema) ParseResourceModelCollection(instance interface{}) []*SchemaInstance

func (*Schema) Table

func (s *Schema) Table() string

func (*Schema) UnmarshalJsonapiPayload

func (s *Schema) UnmarshalJsonapiPayload(in io.Reader, resourceModelInstance interface{}, validate *validator.Validate) (interface{}, error)

type SchemaField

type SchemaField interface {

	// JSONAPIName returns the field's JSON API member name
	JSONAPIName() string

	// PGSelectColumn returns the pg column to use
	// when selecting this field from the database
	PGSelectColumn() string
	// PGFilterColumn returns the pg column to use
	// when filtering by this field from the database
	PGFilterColumn() string

	// Writable returns whether API users may
	// change the value of this field.
	Writable() bool
	// Sortable returns whether API users may
	// sort by this field.
	Sortable() bool
	// Filterable returns whether API users may
	// filter by this field.
	Filterable() bool
	// contains filtered or unexported methods
}

type SchemaInstance

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

A SchemaInstance is an instance of a Schema holding values for each of the Schema fields.

func (*SchemaInstance) GetRelationIds

func (i *SchemaInstance) GetRelationIds() map[*Schema][]int64

GetRelationIds returns all direct (belongsTo) relations to other resource schemas.

func (*SchemaInstance) SortValue added in v0.0.2

func (i *SchemaInstance) SortValue(field SchemaField) interface{}

SortValue returns the schema instance's value for a given field for use when sorting.

func (*SchemaInstance) ToJsonapiModel

func (i *SchemaInstance) ToJsonapiModel() interface{}

ToPGModel creates a new PG Model Instance from the fields of the schema instance.

func (*SchemaInstance) ToPGModel

func (i *SchemaInstance) ToPGModel() interface{}

func (*SchemaInstance) ToResourceModel

func (i *SchemaInstance) ToResourceModel() interface{}

ToResourceModel creates a new Resource Model Instance from the fields of the schema instance.

func (*SchemaInstance) Validate

func (i *SchemaInstance) Validate(validate *validator.Validate) error

Validate validates a schema instance according to validator rules.

type SchemaRegistry

type SchemaRegistry map[reflect.Type]*Schema

func (SchemaRegistry) RegisterSchema

func (r SchemaRegistry) RegisterSchema(modelType reflect.Type) (schema *Schema, err error)

Jump to

Keyboard shortcuts

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