mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
examples/privacy: decision-context example (#841)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user