Skip to content

Commit

Permalink
主键唯一的字段使用First函数查询
Browse files Browse the repository at this point in the history
  • Loading branch information
bin.han committed Feb 9, 2022
1 parent 7aa3ced commit e677f6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion data/view/genfunc/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (obj *_{{$obj.StructName}}Mgr) GetFrom{{$oem.ColStructName}}({{CapLowercase
}
{{else}}
func (obj *_{{$obj.StructName}}Mgr) GetFrom{{$oem.ColStructName}}({{CapLowercase $oem.ColStructName}} {{$oem.Type}}) (result {{$obj.StructName}}, err error) {
err = obj.DB.WithContext(obj.ctx).Model({{$obj.StructName}}{}).Where("{{$oem.ColNameEx}} = ?", {{CapLowercase $oem.ColStructName}}).Find(&result).Error
err = obj.DB.WithContext(obj.ctx).Model({{$obj.StructName}}{}).Where("{{$oem.ColNameEx}} = ?", {{CapLowercase $oem.ColStructName}}).First(&result).Error
{{GenPreloadList $obj.PreloadList false}}
return
}
Expand Down

0 comments on commit e677f6b

Please sign in to comment.