builder

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAndSetID

func GetAndSetID(
	req *http.Request,
	s *scope.Scope,
) (prim interface{}, err error)

GetAndSetID gets the id from the provided request and sets the primary field value to the id If the scope's value is not zero the function returns an error

func GetID

func GetID(query *url.URL, mStruct *models.ModelStruct) (id string, err error)

GetID from the provided query

Types

type JSONAPI

type JSONAPI struct {
	// I18n defines current builder i18n support
	I18n *i18n.Support

	// Config is the configuration for the builder
	Config *config.Builder
	// contains filtered or unexported fields
}

JSONAPI is a struct that is responsible for creating the query scopes

func NewJSONAPI

func NewJSONAPI(c *controller.Controller, cfg *config.Builder, i18nSupport *i18n.Support) *JSONAPI

NewJSONAPI creates new query builder

func (*JSONAPI) BuildRawFilter

func (b *JSONAPI) BuildRawFilter(
	s *scope.Scope,
	raw string,
	values ...interface{},
) (fField *filters.FilterField, err error)

BuildRawFilter build the filter from the provided values, with provided string values

func (*JSONAPI) BuildScopeMany

func (b *JSONAPI) BuildScopeMany(
	ctx context.Context,
	model interface{},
	query *url.URL,
	flgs ...*flags.Container,
) (s *scope.Scope, errs []*aerrors.ApiError, err error)

BuildScopeMany builds the scope for many type

func (*JSONAPI) BuildScopeRelated

func (b *JSONAPI) BuildScopeRelated(
	ctx context.Context,
	model interface{},
	query *url.URL,
	flgs ...*flags.Container,
) (s *scope.Scope, errs []*aerrors.ApiError, err error)

BuildScopeRelated builds the Related scope

func (*JSONAPI) BuildScopeRelationship

func (b *JSONAPI) BuildScopeRelationship(
	ctx context.Context,
	model interface{},
	query *url.URL,
	flgs ...*flags.Container,
) (s *scope.Scope, errs []*aerrors.ApiError, err error)

BuildScopeRelationship builds the relationship kind scope

func (*JSONAPI) BuildScopeSingle

func (b *JSONAPI) BuildScopeSingle(
	ctx context.Context,
	model interface{},
	query *url.URL,
	id interface{},
	flgs ...*flags.Container,
) (s *scope.Scope, errs []*aerrors.ApiError, err error)

BuildScopeSingle builds the scope for the single query with id

func (*JSONAPI) NewRootScope

func (b *JSONAPI) NewRootScope(mStruct *models.ModelStruct) *scope.Scope

NewRootScope creates new root scope for the given model struct

func (*JSONAPI) NewScope

func (b *JSONAPI) NewScope(model interface{}) (*scope.Scope, error)

NewScope creates new scope for provided model

Jump to

Keyboard shortcuts

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