fetchAndExec uses fetchAndQuery but only returns the error. The naming comes from SQL 'exec' functions which only return an error. See fetchAndQuery for more information.
( logger slog.Logger, authorizer rbac.Authorizer, action policy.Action, fetchFunc Fetch, execFunc Exec, )
| 1046 | // from SQL 'exec' functions which only return an error. |
| 1047 | // See fetchAndQuery for more information. |
| 1048 | func fetchAndExec[ |
| 1049 | ObjectType rbac.Objecter, |
| 1050 | ArgumentType any, |
| 1051 | Fetch func(ctx context.Context, arg ArgumentType) (ObjectType, error), |
| 1052 | Exec func(ctx context.Context, arg ArgumentType) error, |
| 1053 | ]( |
| 1054 | logger slog.Logger, |
| 1055 | authorizer rbac.Authorizer, |
| 1056 | action policy.Action, |
| 1057 | fetchFunc Fetch, |
| 1058 | execFunc Exec, |
| 1059 | ) Exec { |
| 1060 | f := fetchAndQuery(logger, authorizer, action, fetchFunc, func(ctx context.Context, arg ArgumentType) (empty ObjectType, err error) { |
| 1061 | return empty, execFunc(ctx, arg) |
| 1062 | }) |
| 1063 | return func(ctx context.Context, arg ArgumentType) error { |
| 1064 | _, err := f(ctx, arg) |
| 1065 | return err |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | // fetchAndQuery is a generic function that wraps a database fetch and query. |
| 1070 | // A query has potential side effects in the database (update, delete, etc). |
no test coverage detected