Documentation
¶
Overview ¶
Package common contains common neuron variables, constants and functions.
Index ¶
Constants ¶
const ( AnnotationPrimary = "primary" AnnotationPrimaryFull = "primary_key" AnnotationPrimaryFullS = "primarykey" AnnotationID = "id" AnnotationPrimaryShort = "pk" )
Model primary field annotation tags.
const ( AnnotationAttribute = "attr" AnnotationAttributeFull = "attribute" )
Model attribute field annotation tags.
const ( AnnotationRelation = "relation" AnnotationRelationFull = "relationship" )
Model relationship field annotation tags.
const ( AnnotationForeignKey = "foreign" AnnotationForeignKeyFull = "foreign_key" AnnotationForeignKeyFullS = "foreignkey" AnnotationForeignKeyShort = "fk" )
Model foreign key field annotation tags.
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" )
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.
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" )
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.
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.
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
const AnnotationClientID = "client-id"
AnnotationClientID states if the primary field could be defined by the client.
const AnnotationLanguage = "lang"
AnnotationLanguage defines the attribute field that contains the language tag. for i18n.
const AnnotationManyToMany = "many2many"
AnnotationManyToMany is the neuron relationship field tag that states this relationship is of type many2many.
const AnnotationNeuron = "neuron"
AnnotationNeuron is the root structfield annotation tag.
const (
// QueryParamLanguage is the language query parameter used in the url.Values.
QueryParamLanguage = "lang"
)
const (
// QueryParamSort is the url query parameter name for the sorting fields.
QueryParamSort = "sort"
)
Sorts Constants
Variables ¶
var ( EncodeLinksCtxKey = EncodeLinks{} // ProcessError is the process error key instance ProcessError = processError{} )
StoreKeys
Functions ¶
func SplitBracketParameter ¶
SplitBracketParameter splits the parameters within the '[' and ']' brackets.
Types ¶
type EncodeLinks ¶
type EncodeLinks struct{}
EncodeLinks is the structure used as a key in the store that states to encode the links for the encoder.