Skip to content

Commit 7e7638c

Browse files
committed
wip
1 parent c740276 commit 7e7638c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

pkg/chartRepo/repository/ChartsRepository.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,23 @@ func (repositoryImpl ChartRepositoryImpl) FindPreviousChartByAppId(appId int) (c
216216
}
217217

218218
func (repositoryImpl ChartRepositoryImpl) Save(tx *pg.Tx, chart *Chart) error {
219+
var connection orm.DB
220+
connection = tx
219221
if tx == nil {
220-
return repositoryImpl.dbConnection.Insert(chart)
221-
} else {
222-
_, err := tx.Model(&chart).Insert()
223-
return err
222+
connection = repositoryImpl.dbConnection
224223
}
224+
_, err := connection.Model(&chart).Insert()
225+
return err
226+
225227
}
226228

227229
func (repositoryImpl ChartRepositoryImpl) Update(tx *pg.Tx, chart *Chart) error {
228-
var query *orm.Query
230+
var connection orm.DB
231+
connection = tx
229232
if tx == nil {
230-
query = tx.Model(chart)
231-
} else {
232-
query = repositoryImpl.dbConnection.Model(chart)
233+
connection = repositoryImpl.dbConnection
233234
}
234-
_, err := query.WherePK().UpdateNotNull()
235+
_, err := connection.Model(chart).WherePK().UpdateNotNull()
235236
return err
236237
}
237238

0 commit comments

Comments
 (0)