refactored db code
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user