Documentation ¶
Overview ¶
Package transformer provides custom transformers for schema fields.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DateTransformer = newDateTransformer()
DateTransformer is a transformer that converts a string in ISO format to primitive.DateTime and vice versa.
View Source
var IDTransformer = newIDTransformer()
IDTransformer is a transformer that converts a string to primitive.ObjectID and vice versa.
Functions ¶
This section is empty.
Types ¶
type Transformer ¶
type Transformer interface { // IsTransformationRequired reports whether the transformer is required for the given field. IsTransformationRequired(field reflect.StructField) bool // TransformForMongoDoc transforms the incoming value according to mongo requirements. TransformForMongoDoc(value interface{}) (interface{}, error) // TransformForEntityModelDoc transforms the incoming value according to entity model requirements. TransformForEntityModelDoc(value interface{}) (interface{}, error) }
Transformer can transform fields in both directions i.e. from entity model to mongo doc and vice versa.
func GetRequiredTransformersForField ¶
func GetRequiredTransformersForField(field reflect.StructField) []Transformer
GetRequiredTransformersForField returns the transformers required for the given field.
Click to show internal directories.
Click to hide internal directories.