MCPcopy
hub / github.com/go-gorm/gorm / Assign

Method Assign

chainable_api.go:439–443  ·  view source on GitHub ↗

Assign provide attributes used in [FirstOrCreate] or [FirstOrInit] Assign adds attributes even if the record is found. If using FirstOrCreate, this means that records will be updated even if they are found. // assign an email regardless of if the record is not found db.Where(User{Name: "non_exis

(attrs ...interface{})

Source from the content-addressed store, hash-verified

437// [FirstOrCreate]: https://gorm.io/docs/advanced_query.html#FirstOrCreate
438// [FirstOrInit]: https://gorm.io/docs/advanced_query.html#FirstOrInit
439func (db *DB) Assign(attrs ...interface{}) (tx *DB) {
440 tx = db.getInstance()
441 tx.Statement.assigns = attrs
442 return
443}
444
445// Unscoped disables the global scope of soft deletion in a query.
446// By default, GORM uses soft deletion, marking records as "deleted"

Callers 4

TestFindOrInitializeFunction · 0.80
TestFindOrCreateFunction · 0.80

Calls 1

getInstanceMethod · 0.95

Tested by 4

TestFindOrInitializeFunction · 0.64
TestFindOrCreateFunction · 0.64