diff --git a/server.go b/server.go index b3f4ef6..c6987c2 100644 --- a/server.go +++ b/server.go @@ -354,9 +354,14 @@ func ConvertInterface(from interface{}, toType reflect.Type) reflect.Value { case reflect.Bool: val, _ := strconv.ParseBool(from.(string)) return reflect.ValueOf(val) + + case reflect.String: + if toType == reflect.TypeOf(primitive.ObjectID{}) { + objid, _ := primitive.ObjectIDFromHex(from.(string)) + return reflect.ValueOf(objid) + } } - logger.Println("ConvertInterface :", fromtype.String(), toType.String(), toType.Kind().String()) return fromrv.Convert(toType) }