# Functions
AnyNil return true if exists any nil value in passed params.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ConvertStructToBSONMap wraps a struct and converts it to a BSON Map, factoring in any options passed as arguments By default, it uses the tag name `bson` on the struct fields to generate the map The mapping is recursive for any data structures contained within the struct
Example StructToBSON to be converted:
type ExampleStruct struct { Value1 string `bson:"myFirstValue"` Value2 []int `bson:"myIntSlice"` }
The struct is first wrapped with the "StructToBSON" type to give access to the mapping functions and is then converted to a bson.M
bson.M { { Key: "myFirstValue", Value: "Example String" }, { Key: "myIntSlice", Value: {1, 2, 3, 4, 5} }, }
The following tag options are factored into the parsing:
// "omitempty" - Omit if the value is the zero value // "omitnested" - Pass the value of the struct directly as opposed to recursively mapping the struct // "flatten" - Pull out the data from the nested struct up one level // "string" - Use the implementation of the Stringer interface for the value // "-" - Do not map this field
.
IsNil function check value is nil or no.
NewBSONMapperStruct returns the input struct wrapped by the mapper struct along with the tag name which should be parsed in the mapping
Panics if the argument is not a struct or pointer to a struct.
ToSnakeCase returns snake_case of the provided value.
# Variables
By default, this package uses `bson` as the tag name You can over-write this once you have wrapped your struct in the mapping struct (StructToBSON) by chaining the .SetTagName() call on the wrapped struct.
# Structs
MappingOpts allows the setting of options which drive the behaviour behind how the struct is parsed.
StructToBson is the wrapper for a struct that enables this package to work.