Attrs provide attributes used in [FirstOrCreate] or [FirstOrInit] Attrs only adds attributes if the record is not found. // assign an email if the record is not found db.Where(User{Name: "non_existing"}).Attrs(User{Email: "fake@fake.org"}).FirstOrInit(&user) // user -> User{Name: "non_existing"
(attrs ...interface{})
| 416 | // [FirstOrCreate]: https://gorm.io/docs/advanced_query.html#FirstOrCreate |
| 417 | // [FirstOrInit]: https://gorm.io/docs/advanced_query.html#FirstOrInit |
| 418 | func (db *DB) Attrs(attrs ...interface{}) (tx *DB) { |
| 419 | tx = db.getInstance() |
| 420 | tx.Statement.attrs = attrs |
| 421 | return |
| 422 | } |
| 423 | |
| 424 | // Assign provide attributes used in [FirstOrCreate] or [FirstOrInit] |
| 425 | // |