MCPcopy Index your code
hub / github.com/coder/coder / fetchAndExec

Function fetchAndExec

coderd/database/dbauthz/dbauthz.go:1048–1067  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

1046// from SQL 'exec' functions which only return an error.
1047// See fetchAndQuery for more information.
1048func 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).

Callers 9

deleteQFunction · 0.85
updateFunction · 0.85
UpdateChatACLByIDMethod · 0.85
UpdateTemplateACLByIDMethod · 0.85

Calls 1

fetchAndQueryFunction · 0.85

Tested by

no test coverage detected