Commit a222be85 authored by szh's avatar szh

update insert

parent 870816af
...@@ -12,8 +12,8 @@ type RaspAddrAccounts struct { ...@@ -12,8 +12,8 @@ type RaspAddrAccounts struct {
} }
func InsertNewAccounts(account *RaspAddrAccounts) error { func InsertNewAccounts(account *RaspAddrAccounts) error {
if err := db.Where(RaspAddrAccounts{Account: account.Account}).Assign(account).FirstOrCreate(account).Error; err != nil { if db.Where(RaspAddrAccounts{Account: account.Account}).First(account).RecordNotFound() {
return err return db.Create(account).Error
} }
return nil return nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment