You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: rule.go
    path of file: ./repos/bk-cmdb/pkg/filter
    
    the code of the file until where you have to start completion: /*
 * Tencent is pleased to support the open source community by making
 * 蓝鲸智云 - 配置平台 (BlueKing - Configuration System) available.
 * Copyright (C) 2017 THL A29 Limited,
 * a Tencent company. All rights reserved.
 * Licensed under the MIT 
    
func (ar *AtomRule) ToMgo(opts ...*RuleOption) (map[string]interface{}, error) {
	if len(opts) > 0 && opts[0] != nil {
		opt := opts[0]
		if len(opt.Parent) == 0 {
			return nil, errors.New("parent is empty")
		}

		switch opt.ParentType {
		case enumor.Object:
			// add object parent field as prefix to generate object filter rules
			return ar.Operator.Operator().ToMgo(opt.Parent+"."+ar.Field, ar.Value)
		case enumor.Array:
			switch ar.Field {
			case ArrayElement:
				// filter array element, matches if any of the elements matches the filter
				return ar.Operator.Operator().ToMgo(opt.Parent, ar.Value)
			default:
				return nil, fmt.Errorf("filter array field %s is invalid", ar.Field)
			}
		default:
			return nil, fmt.Errorf("parent type %s is invalid", opt.ParentType)
		}
	}

	return ar.Operator.Operator().ToMgo(ar.Field, ar.Value)
}