func (d *Postgres) UpdateLog(log *models.Log) error { tx, err := d.db.Begin() if err != nil { return nil } query, args := sqlbuilder.Update(). Dialect(sqlbuilder.Postgres). Table(`"log"`). Set(`"name"`, log.Name). Where(`"id" = ?`, log.ID). Build() _, err = tx.Exec(query, args...) if err != nil { return err } if err := d.replaceLogTags(tx, log); err != nil { tx.Rollback() return err } return tx.Commit() }
func (d *Postgres) UpdateUser(user *models.User) error { query, args := sqlbuilder.Update(). Dialect(sqlbuilder.Postgres). Table(`"user"`). Set(`"username"`, user.Username). Set(`"password"`, user.Password). Set(`"password_version"`, user.PasswordVersion). Build() _, err := d.db.Exec(query, args...) return err }