MCPcopy Index your code
hub / github.com/apache/devlake / CreateOrUpdate

Method CreateOrUpdate

backend/impls/dalgorm/dalgorm.go:263–266  ·  view source on GitHub ↗

CreateOrUpdate tries to create the record, or fallback to update all if failed

(entity interface{}, clauses ...dal.Clause)

Source from the content-addressed store, hash-verified

261
262// CreateOrUpdate tries to create the record, or fallback to update all if failed
263func (d *Dalgorm) CreateOrUpdate(entity interface{}, clauses ...dal.Clause) errors.Error {
264 d.unwrapDynamic(&entity, &clauses)
265 return d.convertGormError(buildTx(d.db, clauses).Clauses(clause.OnConflict{UpdateAll: true}).Create(entity).Error)
266}
267
268// CreateIfNotExist tries to create the record if not exist
269func (d *Dalgorm) CreateIfNotExist(entity interface{}, clauses ...dal.Clause) errors.Error {

Callers

nothing calls this directly

Calls 4

unwrapDynamicMethod · 0.95
convertGormErrorMethod · 0.95
buildTxFunction · 0.85
CreateMethod · 0.65

Tested by

no test coverage detected