Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
goctl
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yao Lei
goctl
Commits
e036f9c7
Commit
e036f9c7
authored
Aug 30, 2022
by
Yuchao Shen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改firstOrUpdate
parent
e15224e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
insert.tpl
1.4.0/model/insert.tpl
+6
-2
No files found.
1.4.0/model/insert.tpl
View file @
e036f9c7
...
...
@@ -13,10 +13,14 @@ func (m *default{{.upperStartCamelObject}}Model) FirstOrCreate(ctx context.Conte
return conn.Save(
&
data).Error
}, {{.keyValues}}){
{
else
}
}var resp {{.upperStartCamelObject}}
err := m.conn.WithContext(ctx).First(
&
resp, where).Error
if err != nil
&&
!errors.Is(err, gorm.ErrRecordNotFound)
{
if err != nil {
return err
}
err = m.conn.WithContext(ctx).Create(data).Error
if errors.Is(err, gorm.ErrRecordNotFound) {
err = m.conn.WithContext(ctx).Create(data).Error
return err
}
return err{
{
end
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment