prepare statement UpdateAccount
This commit is contained in:
parent
478d031275
commit
d0d30ac8ab
|
@ -138,7 +138,10 @@ func (psql PostgresqlStorage) CreateAccount(account Account) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (psql PostgresqlStorage) UpdateAccount(account Account) error {
|
func (psql PostgresqlStorage) UpdateAccount(account Account) error {
|
||||||
updateAccountStmt := "update accounts set namespace=$1, data=$2, metadata=$3 where id= $4"
|
updateAccountStmt, err := psql.DbConnection.Prepare("update accounts set namespace=$1, data=$2, metadata=$3 where id= $4")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
dataAccountJson, err := json.Marshal(account.Data)
|
dataAccountJson, err := json.Marshal(account.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -147,11 +150,14 @@ func (psql PostgresqlStorage) UpdateAccount(account Account) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = psql.DbConnection.Exec(updateAccountStmt, account.Namespace, dataAccountJson, metadataAccountJson, account.ID)
|
_, err = updateAccountStmt.Exec(account.Namespace, dataAccountJson, metadataAccountJson, account.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
updateAccountAuthStmt, err := psql.DbConnection.Prepare("update account_auth set username = $1, password = $2, email = $3, email_validation = $4 ,phone_number = $5,phone_number_validation = $6 where account_id = $7")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
updateAccountAuthStmt := "update account_auth set username = $1, password = $2, email = $3, email_validation = $4 ,phone_number = $5,phone_number_validation = $6 where account_id = $7"
|
|
||||||
emailValidationJson, err := json.Marshal(account.Authentication.Local.EmailValidation)
|
emailValidationJson, err := json.Marshal(account.Authentication.Local.EmailValidation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -160,7 +166,7 @@ func (psql PostgresqlStorage) UpdateAccount(account Account) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = psql.DbConnection.Exec(updateAccountAuthStmt, account.Authentication.Local.Username, account.Authentication.Local.Password, account.Authentication.Local.Email,
|
_, err = updateAccountAuthStmt.Exec(account.Authentication.Local.Username, account.Authentication.Local.Password, account.Authentication.Local.Email,
|
||||||
emailValidationJson, account.Authentication.Local.PhoneNumber, phoneValidationJson, account.ID)
|
emailValidationJson, account.Authentication.Local.PhoneNumber, phoneValidationJson, account.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue