refactored db code

This commit is contained in:
2026-02-09 22:14:38 +11:00
parent bb52790faa
commit fada95a7e4
7 changed files with 24 additions and 100 deletions

View File

@@ -29,12 +29,11 @@ func AssignRole(ctx context.Context, tx bun.Tx, userID, roleID int) error {
UserID: userID,
RoleID: roleID,
}
_, err := tx.NewInsert().
Model(userRole).
err := Insert(tx, userRole).
On("CONFLICT (user_id, role_id) DO NOTHING").
Exec(ctx)
if err != nil {
return errors.Wrap(err, "tx.NewInsert")
return errors.Wrap(err, "db.Insert")
}
return nil