examples/privacy: decision-context example (#841)

This commit is contained in:
Ariel Mashraki
2020-10-12 12:58:49 +03:00
committed by GitHub
parent 190ef15f4e
commit 8b458ebf13

View File

@@ -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
}