common

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package common contains common neuron variables, constants and functions.

Index

Constants

View Source
const (
	AnnotationPrimary      = "primary"
	AnnotationPrimaryFull  = "primary_key"
	AnnotationPrimaryFullS = "primarykey"
	AnnotationID           = "id"
	AnnotationPrimaryShort = "pk"
)

Model primary field annotation tags.

View Source
const (
	AnnotationAttribute     = "attr"
	AnnotationAttributeFull = "attribute"
)

Model attribute field annotation tags.

View Source
const (
	AnnotationRelation     = "relation"
	AnnotationRelationFull = "relationship"
)

Model relationship field annotation tags.

View Source
const (
	AnnotationForeignKey      = "foreign"
	AnnotationForeignKeyFull  = "foreign_key"
	AnnotationForeignKeyFullS = "foreignkey"
	AnnotationForeignKeyShort = "fk"
)

Model foreign key field annotation tags.

View Source
const (
	// AnnotationFilterKey is the model's filter key field tag.
	AnnotationFilterKey = "filterkey"
	// AnnotationNestedField is the model field's neuron tag that defines if the field type is of nested type.
	AnnotationNestedField = "nested"
)
View Source
const (
	AnnotationOnCreate = "on_create"
	AnnotationOnPatch  = "on_patch"
	AnnotationOnDelete = "on_delete"
	AnnotationOrder    = "order"
	AnnotationOnError  = "on_error"
	AnnotationOnChange = "on_change"

	AnnotationRelationRestrict = "restrict"
	AnnotationRelationNoAction = "no-action"
	AnnotationRelationCascade  = "cascade"
	AnnotationRelationSetNull  = "set-null"

	AnnotationFailOnError     = "fail"
	AnnotationContinueOnError = "continue"

	AnnotationDefault = "default"
)

Relation strategy relationship fields tags.

View Source
const (
	// AnnotationName is the neuron model field's tag used to set the NeuronName.
	AnnotationName = "name"
	// AnnotationFieldType is the neuron model field's tag used to set the neuron field type.
	AnnotationFieldType = "type"
)
View Source
const (
	// AnnotationFlags is the neuron model field's tag used for defining field flags.
	AnnotationFlags = "flags"
	// AnnotationHidden defines that the field should be hidden from marshaling.
	AnnotationHidden = "hidden"
	// AnnotationISO8601 sets the time field format to ISO8601.
	AnnotationISO8601 = "iso8601"
	// AnnotationOmitEmpty allows to omit marshaling this field if it's zero-value.
	AnnotationOmitEmpty = "omitempty"
	// AnnotationI18n defines that this field is internationalization ready.
	AnnotationI18n = "i18n"
	// AnnotationNoFilter is the neuron model field's flag that disallows to query filter for given field.
	AnnotationNoFilter = "nofilter"
	// AnnotationNotSortable is the neuron model field's flag that disallows to query sort on given field.
	AnnotationNotSortable = "nosort"
)

Model field's flag tags.

View Source
const (
	// AnnotationSeparator is the symbol used to separate the subtags for given neuron tag.
	// Example: `neuron:"many2many=foreign,related_foreign"`
	//										 ^
	AnnotationSeparator = ","

	// AnnotationTagSeparator is the symbol used to separate neuron based tags.
	// Example: `neuron:"type=attr;name=custom_name"`
	//								 ^
	AnnotationTagSeparator = ";"
	// AnnotationTagEqual is the symbol used to set the values for the for given neuron tag.
	// Example: `neuron:"type=attr"`
	//						    ^
	AnnotationTagEqual = '='

	// AnnotationNestedSeparator is the symbol used as a separator for the nested fields access.
	// Used in included or sort fields.
	// Example: field.relationship.
	// 				    ^
	AnnotationNestedSeparator = "."

	// AnnotationOpenedBracket is the symbol used in filtering system
	// which is used to open new logical part.
	// Example: filter[collection][name][$operator]
	//				  ^           ^     ^
	AnnotationOpenedBracket = '['

	// AnnotationClosedBracket is the symbol used in filtering system
	// which is used to open new logical part.
	// Example: filter[collection][name][$operator]
	//				  			 ^     ^          ^
	AnnotationClosedBracket = ']'
)

Separators and other symbols.

View Source
const (
	// QueryParamPage is a JSON API query parameter used as for pagination.
	QueryParamPage = "page"

	// QueryParamPageNumber is a JSON API query parameter used in a page based
	// pagination strategy in conjunction with QueryParamPageSize.
	QueryParamPageNumber = "page[number]"
	// QueryParamPageSize is a JSON API query parameter used in a page based
	// pagination strategy in conjunction with QueryParamPageNumber.
	QueryParamPageSize = "page[size]"

	// QueryParamPageOffset is a JSON API query parameter used in an offset based
	// pagination strategy in conjunction with QueryParamPageLimit.
	QueryParamPageOffset = "page[offset]"
	// QueryParamPageLimit is a JSON API query parameter used in an offset based
	// pagination strategy in conjunction with QueryParamPageOffset.
	QueryParamPageLimit = "page[limit]"

	// QueryParamPageCursor is a JSON API query parameter used with a cursor-based
	// strategy.
	QueryParamPageCursor = "page[cursor]"

	// QueryParamPageTotal is a JSON API query parameter used in pagination
	// It tells to API to add information about total-pages or total-count
	// (depending on the current strategy).
	QueryParamPageTotal = "page[total]"
)

Pagination constants

View Source
const AnnotationClientID = "client-id"

AnnotationClientID states if the primary field could be defined by the client.

View Source
const AnnotationLanguage = "lang"

AnnotationLanguage defines the attribute field that contains the language tag. for i18n.

View Source
const AnnotationManyToMany = "many2many"

AnnotationManyToMany is the neuron relationship field tag that states this relationship is of type many2many.

View Source
const AnnotationNeuron = "neuron"

AnnotationNeuron is the root structfield annotation tag.

View Source
const (
	// QueryParamLanguage is the language query parameter used in the url.Values.
	QueryParamLanguage = "lang"
)
View Source
const (
	// QueryParamSort is the url query parameter name for the sorting fields.
	QueryParamSort = "sort"
)

Sorts Constants

Variables

View Source
var (
	EncodeLinksCtxKey = EncodeLinks{}
	// ProcessError is the process error key instance
	ProcessError = processError{}
)

StoreKeys

Functions

func SplitBracketParameter

func SplitBracketParameter(bracketed string) (values []string, err error)

SplitBracketParameter splits the parameters within the '[' and ']' brackets.

Types

type EncodeLinks struct{}

EncodeLinks is the structure used as a key in the store that states to encode the links for the encoder.

Jump to

Keyboard shortcuts

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