func (VS *Server) addInformationAuditItself(audit Audit, object interface{}) Audit {
	var number int
	var date int64
	var boolean bool
	var arrayID []bson.ObjectId
	var arrayString []string
	audit.InformationObject = make(map[string]string)
	for i := 0; i < reflect.ValueOf(object).NumField(); i++ {
		nameAtribute := reflect.TypeOf(object).Field(i).Name
		if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(bson.NewObjectId()) {
			// Is a BSON ID Object!
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().(bson.ObjectId)
			audit.InformationObject[nameAtribute] = valueAttribute.Hex()
		} else if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(number) {
			// Is an int
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().(int)
			audit.InformationObject[nameAtribute] = strconv.Itoa(valueAttribute)
		} else if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(date) {
			// Is an int
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().(int64)
			audit.InformationObject[nameAtribute] = strconv.FormatInt(valueAttribute, 10)
		} else if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(boolean) {
			// Is a bool
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().(bool)
			audit.InformationObject[nameAtribute] = strconv.FormatBool(valueAttribute)
		} else if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(arrayID) {
			// Is a IDArrays
			// valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().(arrayID)
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().([]bson.ObjectId)
			for _, id := range valueAttribute {
				audit.InformationObject[nameAtribute] = id.Hex()
			}

		} else if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(arrayString) {
			// Is a ArrayString
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().([]string)
			for _, data := range valueAttribute {
				audit.InformationObject[nameAtribute] = data
			}
		} else {
			valueAttribute := reflect.ValueOf(object).Field(i).String()
			audit.InformationObject[nameAtribute] = valueAttribute
		}
	}
	return audit
}
// This method iterates over the Attributes of an Struct, and add all the information in the Audit
This method iterates over the Attributes of an Struct, and add all the information in the Audit
// This method iterates over the Attributes of an Struct and add all the information in the Audit
func (VS *Server) addInformationAuditItself(audit Audit, object interface{}) Audit {
	var number int
	var date int64
	var boolean bool
	var arrayID []bson.ObjectId
	var arrayString []string
	audit.InformationObject = make(map[string]string)
	for i := 0; i < reflect.ValueOf(object).NumField(); i++ {
		nameAtribute := reflect.TypeOf(object).Field(i).Name
		if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(bson.NewObjectId()) {
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().(bson.ObjectId)
			audit.InformationObject[nameAtribute] = valueAttribute.Hex()
		} else if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(number) {
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().(int)
			audit.InformationObject[nameAtribute] = strconv.Itoa(valueAttribute)
		} else if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(date) {
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().(int64)
			audit.InformationObject[nameAtribute] = strconv.FormatInt(valueAttribute, 10)
		} else if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(boolean) {
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().(bool)
			audit.InformationObject[nameAtribute] = strconv.FormatBool(valueAttribute)
		} else if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(arrayID) {
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().([]bson.ObjectId)
			for _, id := range valueAttribute {
				audit.InformationObject[nameAtribute] = id.Hex()
			}
		} else if reflect.TypeOf(object).Field(i).Type == reflect.TypeOf(arrayString) {
			valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().([]string)
			for _, data := range valueAttribute {
				audit.InformationObject[nameAtribute] = data
			}
		} else {
			valueAttribute := reflect.ValueOf(object).Field(i).String()
			audit.InformationObject[nameAtribute] = valueAttribute
		}
	}
	return audit
}
func ( VS * Server ) addInformationAuditItself ( audit Audit , object interface { } ) Audit { var number int var date int64 var boolean bool var arrayID [ ] bson . ObjectId var arrayString [ ] string audit . InformationObject = make ( map [ string ] string ) for i := 0 ; i < reflect . ValueOf ( object ) . NumField ( ) ; i ++ { nameAtribute := reflect . TypeOf ( object ) . Field ( i ) . Name if reflect . TypeOf ( object ) . Field ( i ) . Type == reflect . TypeOf ( bson . NewObjectId ( ) ) { valueAttribute , _ := reflect . ValueOf ( object ) . Field ( i ) . Interface ( ) . ( bson . ObjectId ) audit . InformationObject [ nameAtribute ] = valueAttribute . Hex ( ) } else if reflect . TypeOf ( object ) . Field ( i ) . Type == reflect . TypeOf ( number ) { valueAttribute , _ := reflect . ValueOf ( object ) . Field ( i ) . Interface ( ) . ( int ) audit . InformationObject [ nameAtribute ] = strconv . Itoa ( valueAttribute ) } else if reflect . TypeOf ( object ) . Field ( i ) . Type == reflect . TypeOf ( date ) { valueAttribute , _ := reflect . ValueOf ( object ) . Field ( i ) . Interface ( ) . ( int64 ) audit . InformationObject [ nameAtribute ] = strconv . FormatInt ( valueAttribute , 10 ) } else if reflect . TypeOf ( object ) . Field ( i ) . Type == reflect . TypeOf ( boolean ) { valueAttribute , _ := reflect . ValueOf ( object ) . Field ( i ) . Interface ( ) . ( bool ) audit . InformationObject [ nameAtribute ] = strconv . FormatBool ( valueAttribute ) } else if reflect . TypeOf ( object ) . Field ( i ) . Type == reflect . TypeOf ( arrayID ) { valueAttribute , _ := reflect . ValueOf ( object ) . Field ( i ) . Interface ( ) . ( [ ] bson . ObjectId ) for _ , id := range valueAttribute { audit . InformationObject [ nameAtribute ] = id . Hex ( ) } } else if reflect . TypeOf ( object ) . Field ( i ) . Type == reflect . TypeOf ( arrayString ) { valueAttribute , _ := reflect . ValueOf ( object ) . Field ( i ) . Interface ( ) . ( [ ] string ) for _ , data := range valueAttribute { audit . InformationObject [ nameAtribute ] = data } } else { valueAttribute := reflect . ValueOf ( object ) . Field ( i ) . String ( ) audit . InformationObject [ nameAtribute ] = valueAttribute } } return audit }
This method iterates over the Attributes of an Struct, and add all the information in the Audit
This method iterates over the Attributes of an Struct and add all the information in the Audit
// Is a BSON ID Object! // Is an int // Is an int // Is a bool // Is a IDArrays // valueAttribute, _ := reflect.ValueOf(object).Field(i).Interface().(arrayID) // Is a ArrayString