Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDynMapConvertable

func IsDynMapConvertable(value interface{}) bool

    Returns true if the given value is a map, dynmap, DynMaper or pointer of one of those types

    func Less

    func Less(val1, val2 interface{}) bool

      big sort func.

      func MustBool

      func MustBool(value interface{}, def bool) bool

      func MustInt

      func MustInt(value interface{}, def int) int

      func MustString

      func MustString(value interface{}, def string) string

      func PrettyJSON

      func PrettyJSON(obj interface{}) string

        attempts to convert the passed in object to a dynmap then JSON, ignoring any errors

        func Sort

        func Sort(vals []DynMap, sortCol string)

        func ToArray

        func ToArray(value interface{}) ([]interface{}, bool)

          convert the object into an array if possible

          func ToBool

          func ToBool(value interface{}) (bool, error)

          func ToFloat64

          func ToFloat64(value interface{}) (f float64, err error)

          func ToInt

          func ToInt(value interface{}) (int, error)

          func ToInt64

          func ToInt64(value interface{}) (i int64, err error)

          func ToMap

          func ToMap(value interface{}) (map[string]interface{}, bool)

            attempts to convert the given value to a map. returns

            func ToSortVal

            func ToSortVal(value interface{}) (interface{}, int)

              cleans up to one of the types we know about, attempting to convert: the conversion here is not as aggressive as the above methods. Will deference any pointers but strings will not be attempted to be parsed dynmap time int64 bool string

              integer returned is the sort order, so bool < int < string < time < map

              func ToString

              func ToString(value interface{}) string

              func ToTime

              func ToTime(value interface{}) (tm time.Time, err error)

                parse time

                Types

                type DynMap

                type DynMap struct {
                	Map map[string]interface{} `bson:",inline"`
                }

                  Dont make this a map type, since we want the option of extending this and adding members.

                  func Convert

                  func Convert(obj interface{}) (*DynMap, error)

                    creates a dynmap from the passed in object, if possible

                    func New

                    func New() *DynMap

                      Creates a new dynmap

                      func ParseJSON

                      func ParseJSON(json string) (*DynMap, error)

                      func ToDynMap

                      func ToDynMap(value interface{}) (*DynMap, bool)

                      func Wrap

                      func Wrap(mp map[string]interface{}) *DynMap

                      func (DynMap) AddToSlice

                      func (this DynMap) AddToSlice(key string, mp ...interface{}) error

                        Adds the item to a slice

                        func (DynMap) AddToSliceWithDot

                        func (this DynMap) AddToSliceWithDot(key string, mp ...interface{}) error

                          Adds the item to a slice

                          func (*DynMap) Clone

                          func (dm *DynMap) Clone() *DynMap

                            Recursive clone

                            func (DynMap) Contains

                            func (this DynMap) Contains(key string) bool

                            func (DynMap) ContainsAll

                            func (this DynMap) ContainsAll(keys ...string) bool

                            func (DynMap) ContainsDynMap

                            func (this DynMap) ContainsDynMap(key string) bool

                            func (DynMap) ContainsString

                            func (this DynMap) ContainsString(key string) bool

                            func (*DynMap) ConvertTo

                            func (this *DynMap) ConvertTo(val interface{}) error

                              Attempts to fill the given struct with the values contained in this dynmap.

                              func (*DynMap) Exists

                              func (this *DynMap) Exists(key string) bool

                              func (*DynMap) Flatten

                              func (this *DynMap) Flatten() map[string]interface{}

                                flattens this dynmap into a one level map where all keys use the dot operator, and values are not maps (primitives or objects) arrays and slices are indexed by integer for instance key1: ["v1", "v2"] => key1.0:v1, key1.1:v2 Note that the slice syntax is not supported yet by PutWithDot so flattened keys cannot be automatically used to recreate the nested map (todo)

                                func (*DynMap) Get

                                func (this *DynMap) Get(key string) (interface{}, bool)

                                  Get's the value. will honor the dot operator if needed. key = 'map.map2' will first attempt to matche the literal key 'map.map2' if no value is present it will look for a sub map at key 'map'

                                  func (DynMap) GetBool

                                  func (this DynMap) GetBool(key string) (bool, bool)

                                  func (DynMap) GetDynMap

                                  func (this DynMap) GetDynMap(key string) (*DynMap, bool)

                                    Gets a dynmap from the requested. This will update the value in the map if the value was not already a dynmap.

                                    func (DynMap) GetDynMapSlice

                                    func (this DynMap) GetDynMapSlice(key string) ([]*DynMap, bool)

                                      gets a slice of dynmaps

                                      func (DynMap) GetFloat64

                                      func (this DynMap) GetFloat64(key string) (float64, bool)

                                      func (DynMap) GetInt

                                      func (this DynMap) GetInt(key string) (int, bool)

                                      func (DynMap) GetInt64

                                      func (this DynMap) GetInt64(key string) (int64, bool)

                                        Gets the value at the specified key as an int64. returns -1,false if value not available or is not convertable

                                        func (DynMap) GetIntSlice

                                        func (this DynMap) GetIntSlice(key string) ([]int, bool)

                                          Returns a slice of ints

                                          func (DynMap) GetIntSliceSplit

                                          func (this DynMap) GetIntSliceSplit(key, delim string) ([]int, bool)

                                            gets a slice of ints. if the value is a string it will split by the requested delimiter

                                            func (DynMap) GetString

                                            func (this DynMap) GetString(key string) (string, bool)

                                              Gets a string representation of the value at key

                                              func (DynMap) GetStringSlice

                                              func (this DynMap) GetStringSlice(key string) ([]string, bool)

                                                Returns a slice of strings

                                                func (DynMap) GetStringSliceSplit

                                                func (this DynMap) GetStringSliceSplit(key, delim string) ([]string, bool)

                                                  gets a slice of strings. if the value is a string it will split by the requested delimiter

                                                  func (DynMap) GetTime

                                                  func (this DynMap) GetTime(key string) (time.Time, bool)

                                                  func (*DynMap) IsEmpty

                                                  func (this *DynMap) IsEmpty() bool

                                                  func (*DynMap) Length

                                                  func (this *DynMap) Length() int

                                                  func (DynMap) MarshalJSON

                                                  func (this DynMap) MarshalJSON() ([]byte, error)

                                                  func (*DynMap) MarshalUrl

                                                  func (this *DynMap) MarshalUrl() (string, error)

                                                    encodes this map into a url encoded string. maps are encoded in the rails style (key[key2][key2]=value) TODO: we should sort the keynames so ordering is consistent and then this can be used a cache key

                                                    func (*DynMap) Merge

                                                    func (this *DynMap) Merge(mp *DynMap) *DynMap

                                                      recursively merges the requested dynmap into the current dynmap returns self in order to support chaining.

                                                      func (*DynMap) Must

                                                      func (this *DynMap) Must(key string, def interface{}) interface{}

                                                      func (DynMap) MustBool

                                                      func (this DynMap) MustBool(key string, def bool) bool

                                                      func (DynMap) MustDynMap

                                                      func (this DynMap) MustDynMap(key string, def *DynMap) *DynMap

                                                      func (DynMap) MustDynMapSlice

                                                      func (this DynMap) MustDynMapSlice(key string, def []*DynMap) []*DynMap

                                                      func (DynMap) MustFloat64

                                                      func (this DynMap) MustFloat64(key string, def float64) float64

                                                      func (DynMap) MustInt

                                                      func (this DynMap) MustInt(key string, def int) int

                                                      func (DynMap) MustInt64

                                                      func (this DynMap) MustInt64(key string, def int64) int64

                                                      func (DynMap) MustString

                                                      func (this DynMap) MustString(key string, def string) string

                                                        gets a string. if string is not available in the map, then the default is returned

                                                        func (DynMap) MustStringSlice

                                                        func (this DynMap) MustStringSlice(key string, def []string) []string

                                                        func (DynMap) MustTime

                                                        func (this DynMap) MustTime(key string, def time.Time) time.Time

                                                        func (*DynMap) Put

                                                        func (this *DynMap) Put(key string, value interface{})

                                                          Put's a value into the map

                                                          func (*DynMap) PutAll

                                                          func (this *DynMap) PutAll(mp interface{}) bool

                                                            puts all the values from the passed in map into this dynmap the passed in map must be convertable to a DynMap via ToDynMap. returns false if the passed value is not convertable to dynmap

                                                            func (*DynMap) PutIfAbsent

                                                            func (this *DynMap) PutIfAbsent(key string, value interface{}) (interface{}, bool)

                                                              Puts the value into the map if and only if no value exists at the specified key. This does not honor the dot operator on insert.

                                                              func (*DynMap) PutIfAbsentWithDot

                                                              func (this *DynMap) PutIfAbsentWithDot(key string, value interface{}) (interface{}, bool)

                                                                Same as PutIfAbsent but honors the dot operator

                                                                func (*DynMap) PutWithDot

                                                                func (this *DynMap) PutWithDot(key string, value interface{}) error

                                                                  puts the value into the map, honoring the dot operator. so PutWithDot("map1.map2.value", 100) would result in: {

                                                                  map1 : { map2 : { value: 100 }}
                                                                  

                                                                  }

                                                                  func (*DynMap) Remove

                                                                  func (this *DynMap) Remove(key string) (interface{}, bool)

                                                                    Remove a mapping

                                                                    func (*DynMap) RemoveAll

                                                                    func (dm *DynMap) RemoveAll(key ...string)

                                                                    func (*DynMap) ToDynMap

                                                                    func (this *DynMap) ToDynMap() *DynMap

                                                                      Returns self. Here so that we satisfy the DynMaper interface

                                                                      func (DynMap) ToJSON

                                                                      func (this DynMap) ToJSON() string

                                                                        converts to indented json, throws away any errors this is useful for logging purposes. MarshalJSON should be used for most uses.

                                                                        func (*DynMap) ToMap

                                                                        func (this *DynMap) ToMap() map[string]interface{}

                                                                          Recursively converts this to a regular go map. (will convert any sub maps)

                                                                          func (*DynMap) UnFlatten

                                                                          func (dm *DynMap) UnFlatten() (*DynMap, error)

                                                                            Takes any dot operator keys and makes nested maps returns a new DynMap instance

                                                                            func (*DynMap) UnmarshalJSON

                                                                            func (this *DynMap) UnmarshalJSON(bytes []byte) error

                                                                            func (*DynMap) UnmarshalUrl

                                                                            func (this *DynMap) UnmarshalUrl(urlstring string) error

                                                                              Unmarshals a url encoded string. will also parse rails style maps in the form key[key1][key2]=val

                                                                              func (*DynMap) UnmarshalUrlValues

                                                                              func (this *DynMap) UnmarshalUrlValues(values url.Values) error

                                                                                Unmarshals url.Values into the map. Will correctly handle rails style maps in the form key[key1][key2]=val

                                                                                type DynMapSlice

                                                                                type DynMapSlice struct {
                                                                                	// contains filtered or unexported fields
                                                                                }

                                                                                func NewDynMapSlice

                                                                                func NewDynMapSlice(vals []DynMap, sortCol string) DynMapSlice

                                                                                func (DynMapSlice) Len

                                                                                func (dms DynMapSlice) Len() int

                                                                                func (DynMapSlice) Less

                                                                                func (dms DynMapSlice) Less(i, j int) bool

                                                                                func (DynMapSlice) Swap

                                                                                func (dms DynMapSlice) Swap(i, j int)

                                                                                type DynMaper

                                                                                type DynMaper interface {
                                                                                	ToDynMap() *DynMap
                                                                                }