Skip to content

Mapper doesn't work on composition #39

@naeemaei

Description

@naeemaei

I have this models that wants to map a slice of Country to a slice of CountryRes

Source:

// Base model
type BaseModel struct {
	Id    int    `json:"id"`
}

// Country model
type Country struct {
	BaseModel
	Name string `json:"name"`
}

//
type CountryRes struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

When I want to map a slice of Country to a slice of CountryRes the Id field has been ignored.

var items *[]Country = new([]Country)
var mitems *[]CountryRes = new([]CountryRes)
err = mapper.MapperSlice(items, mitems) 

The execution didn't have any errors but the Id field had been ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions