feat(api): add PATCH /users/@me, remove PATCH /users/@me/fields
This commit is contained in:
parent
f4a6296d13
commit
57c7a0f4de
6 changed files with 188 additions and 67 deletions
|
@ -91,13 +91,7 @@ func (db *DB) UserFields(ctx context.Context, id xid.ID) (fs []Field, err error)
|
|||
}
|
||||
|
||||
// SetUserFields updates the fields for the given user.
|
||||
func (db *DB) SetUserFields(ctx context.Context, userID xid.ID, fields []Field) (err error) {
|
||||
tx, err := db.Begin(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "building sql")
|
||||
}
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
func (db *DB) SetUserFields(ctx context.Context, tx pgx.Tx, userID xid.ID, fields []Field) (err error) {
|
||||
sql, args, err := sq.Delete("user_fields").Where("user_id = ?", userID).ToSql()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "building sql")
|
||||
|
@ -124,10 +118,5 @@ func (db *DB) SetUserFields(ctx context.Context, userID xid.ID, fields []Field)
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "inserting new fields")
|
||||
}
|
||||
|
||||
err = tx.Commit(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "committing transaction")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue