Пример #1
0
func ModelFieldToSqlField(field reflect.StructField) string {
	if name := field.Tag.Get("name"); name != "" {
		return name
	}

	return toolkit.CamelCaseToUnderScore(field.Name)
}
Пример #2
0
func ModelTableName(model ModelInterface) string {
	if name := model.TableName(); name != DefaultTable {
		return name
	} else {
		modelType := reflect.ValueOf(model).Elem().Type()
		modelName := modelType.Name()
		return toolkit.CamelCaseToUnderScore(modelName)
	}
}