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: filter.go
    path of file: ./repos/shellhub/pkg/models
    
    the code of the file until where you have to start completion: package models

import (
	"encoding/json"
)

// Filter is a helper struct to filter results from the database.
// TODO: Gives a better explanation about the filter and how to use it.
type Filter struct {
	// Type os the filter. Type can be "property" or "operator". When Type is "property", the Params field must is set
	// to PropertyParams structure and when set "operator", the Params field must be set to OperatorParams s
    
func (f *Filter) UnmarshalJSON(data []byte) error {
	var params json.RawMessage

	type filter Filter
	aux := filter{
		Params: &params,
	}

	if err := json.Unmarshal(data, &aux); err != nil {
		return err
	}

	switch aux.Type {
	case "property":
		var property PropertyParams
		if err := json.Unmarshal(params, &property); err != nil {
			return err
		}
		f.Params = &property
	case "operator":
		var operator OperatorParams
		if err := json.Unmarshal(params, &operator); err != nil {
			return err
		}
		f.Params = &operator
	}

	f.Type = aux.Type

	return nil
}