Documentation
¶
Overview ¶
Package enttenant adapts GoTenancy data filters to Ent SQL selectors.
Index ¶
- Variables
- func Apply(ctx context.Context, selector *sql.Selector, config Config) error
- func FilterMutation(ctx context.Context, mutation Mutation, config Config) error
- func FilterQuery(ctx context.Context, query Query, config Config) error
- func Hook(config Config) ent.Hook
- type Config
- type Mutation
- type MutationFilter
- type Query
- type QueryFilter
- type SelectorPredicate
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilQuery reports that a nil Ent query was passed to the tenant filter. ErrNilQuery = errors.New("gotenancy/ent: nil query") // ErrNilMutation reports that a nil Ent mutation was passed to the tenant filter. ErrNilMutation = errors.New("gotenancy/ent: nil mutation") // ErrUnsupportedMutation reports that an Ent mutation does not expose storage predicates. ErrUnsupportedMutation = errors.New("gotenancy/ent: unsupported mutation") // ErrTenantFieldNotFound reports that the configured tenant field does not exist on the mutation. ErrTenantFieldNotFound = errors.New("gotenancy/ent: tenant field not found") )
Functions ¶
func FilterMutation ¶
FilterMutation applies tenant isolation to mutation using config.
func FilterQuery ¶
FilterQuery applies tenant isolation to query using config.
Types ¶
type Mutation ¶
type Mutation interface {
Op() ent.Op
WhereP(...SelectorPredicate)
Field(string) (ent.Value, bool)
SetField(string, ent.Value) error
}
Mutation is the storage-level predicate surface generated by Ent mutations.
type MutationFilter ¶
type MutationFilter struct {
// contains filtered or unexported fields
}
MutationFilter applies tenant guards to Ent mutations.
func NewMutationFilter ¶
func NewMutationFilter(config Config) MutationFilter
NewMutationFilter creates a reusable Ent mutation tenant filter.
type Query ¶
type Query interface {
WhereP(...SelectorPredicate)
}
Query is the storage-level predicate surface generated by Ent query builders.
type QueryFilter ¶
type QueryFilter struct {
// contains filtered or unexported fields
}
QueryFilter applies tenant predicates to Ent query builders.
func NewQueryFilter ¶
func NewQueryFilter(config Config) QueryFilter
NewQueryFilter creates a reusable Ent query tenant filter.
type SelectorPredicate ¶
SelectorPredicate is an Ent custom predicate that mutates a SQL selector.
func Predicate ¶
func Predicate(ctx context.Context, config Config) (SelectorPredicate, error)
Predicate builds an Ent custom predicate from the tenant context.
func TenantPredicate ¶
func TenantPredicate(ctx context.Context) (SelectorPredicate, error)
TenantPredicate builds an Ent custom predicate with default configuration.