From 8b458ebf137efca23afcb196948dfc639cb2fb13 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki <7413593+a8m@users.noreply.github.com> Date: Mon, 12 Oct 2020 12:58:49 +0300 Subject: [PATCH] examples/privacy: decision-context example (#841) --- examples/privacyadmin/example_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/privacyadmin/example_test.go b/examples/privacyadmin/example_test.go index 752eb1046..75eb09dca 100644 --- a/examples/privacyadmin/example_test.go +++ b/examples/privacyadmin/example_test.go @@ -61,5 +61,10 @@ func Do(ctx context.Context, client *ent.Client) error { count := client.User.Query().CountX(ctx) fmt.Println(count) } + // Bind a privacy decision to the context (bypass all other rules). + allow := privacy.DecisionContext(ctx, privacy.Allow) + if _, err := client.User.Create().Save(allow); err != nil { + return fmt.Errorf("expect operation to pass, but got %v", err) + } return nil }