shared/generate/db/mapping.go
func (m *Mapping) NaturalKey() []*Field {
	key := []*Field{}

	for _, field := range m.Fields {
		if field.Config.Get("primary") != "" {
			key = append(key, field)
		}
	}

	if len(key) == 0 {
		// Default primary key.
		key = append(key, m.FieldByName("Name"))
	}

	return key
}
func (m *Mapping) NaturalKey() []*Field {
	key := []*Field{}

	for _, field := range m.Fields {
		if field.Config.Get("primary") != "" {
			key = append(key, field)
		}
	}

	if len(key) == 0 {
		// Default primary key.
		key = append(key, m.FieldByName("Name"))
	}

	return key
}
func ( m * Mapping ) NaturalKey ( ) [ ] * Field { key := [ ] * Field { } for _ , field := range m . Fields { if field . Config . Get ( " " ) != " " { key = append ( key , field ) } } if len ( key ) == 0 { // Default primary key. key = append ( key , m . FieldByName ( " " ) ) } return key }
// NaturalKey returns the struct fields that can be used as natural key for
// uniquely identifying a row in the underlying table (==.
//
// By convention the natural key field is the one called "Name", unless
// specified otherwise with the `db:natural_key` tags.
NaturalKey returns the struct fields that can be used as natural key for uniquely identifying a row in the underlying table ( == . By convention the natural key field is the one called Name unless specified otherwise with the db : natural_key tags .