func (l *Location) IsMainLocation() bool {
	return l.MainID == l.ID
}
If the location is main location
package contenttype
import (
	"context"
	"database/sql"
	"strings"
	"github.com/digimakergo/digimaker/core/db"
	"github.com/digimakergo/digimaker/core/definition"
	"github.com/digimakergo/digimaker/core/util"
)
type Location struct {
	ID             int    `boil:"id" json:"id" toml:"id" yaml:"id"`
	ParentID       int    `boil:"parent_id" json:"parent_id" toml:"parent_id" yaml:"parent_id"`
	MainID         int    `boil:"main_id" json:"main_id" toml:"main_id" yaml:"main_id"`
	IdentifierPath string `boil:"identifier_path" json:"identifier_path" toml:"identifier_path" yaml:"identifier_path"`
	Hierarchy      string `boil:"hierarchy" json:"hierarchy" toml:"hierarchy" yaml:"hierarchy"`
	Depth          int    `boil:"depth" json:"depth" toml:"depth" yaml:"depth"`
	ContentType    string `boil:"content_type" json:"content_type" toml:"content_type" yaml:"content_type"`
	ContentID      int    `boil:"content_id" json:"content_id" toml:"content_id" yaml:"content_id"`
	Language       string `boil:"language" json:"language" toml:"language" yaml:"language"`
	Name           string `boil:"name" json:"name" toml:"name" yaml:"name"`
	IsHidden       bool   `boil:"is_hidden" json:"is_hidden" toml:"is_hidden" yaml:"is_hidden"`
	IsInvisible    bool   `boil:"is_invisible" json:"is_invisible" toml:"is_invisible" yaml:"is_invisible"`
	Priority       int    `boil:"priority" json:"priority" toml:"priority" yaml:"priority"`
	UID            string `boil:"uid" json:"uid" toml:"uid" yaml:"uid"`
	Section        string `boil:"section" json:"section" toml:"section" yaml:"section"`
	P              string `boil:"p" json:"p" toml:"p" yaml:"p"`
	path           []int  `boil:"-"`
}
func (c *Location) ToDBValues() map[string]interface{} {
	result := make(map[string]interface{})
	result["id"] = c.ID
	result["parent_id"] = c.ParentID
	result["identifier_path"] = c.IdentifierPath
	result["main_id"] = c.MainID
	result["hierarchy"] = c.Hierarchy
	result["depth"] = c.Depth
	result["content_type"] = c.ContentType
	result["content_id"] = c.ContentID
	result["language"] = c.Language
	result["name"] = c.Name
	result["is_hidden"] = c.IsHidden
	result["is_invisible"] = c.IsInvisible
	result["priority"] = c.Priority
	result["uid"] = c.UID
	result["section"] = c.Section
	result["p"] = c.P
	return result
}
func (c *Location) GetID() int {
	return c.ID
}
func (c *Location) TableName() string {
	return "dm_location"
}
func (c *Location) IdentifierList() []string {
	return definition.LocationColumns
}
func (c *Location) Field(name string) interface{} {
	var result interface{}
	switch name {
	case "id", "ID":
		result = c.ID
	case "parent_id", "ParentID":
		result = c.ParentID
	case "main_id", "MainID":
		result = c.MainID
	case "hierarchy", "Hierarchy":
		result = c.Hierarchy
	case "depth", "Depth":
		result = c.Depth
	case "content_type", "ContentType":
		result = c.ContentType
	case "content_id", "ContentID":
		result = c.ContentID
	case "language", "Language":
		result = c.Language
	case "name", "Name":
		result = c.Name
	case "is_hidden", "IsHidden":
		result = c.IsHidden
	case "is_invisible", "IsInvisible":
		result = c.IsInvisible
	case "priority", "Priority":
		result = c.Priority
	case "uid", "UID":
		result = c.UID
	case "section", "Section":
		result = c.Section
	case "p", "P":
		result = c.P
	default:
	}
	return result
}
func (c *Location) Path() []int {
	if len(c.path) == 0 {
		path := strings.Split(c.Hierarchy, "/")
		c.path, _ = util.ArrayStrToInt(path)
	}
	return c.path
}
func (c *Location) Store(ctx context.Context, transaction ...*sql.Tx) error {
	if c.ID == 0 {
		id, err := db.Insert(ctx, c.TableName(), c.ToDBValues(), transaction...)
		c.ID = id
		if err != nil {
			return err
		}
	} else {
		err := db.Update(ctx, c.TableName(), c.ToDBValues(), db.Cond("id", c.ID), transaction...)
		return err
	}
	return nil
}
func (l *Location) CountLocations() int {
	count, err := db.Count("dm_location", db.Cond("content_type", l.ContentType).Cond("content_id", l.ContentID))
	if err != nil {
	}
	return count
}