Documentation
¶
Index ¶
- Variables
- func AuditHook(next ent.Mutator) ent.Mutator
- func GetTenantRules(filers []string, tid string, selector *sql.Selector) []*sql.Predicate
- func SkipSoftDelete(parent context.Context) context.Context
- func SkipTenantPrivacy(parent context.Context) context.Context
- type Annotation
- type AuditMixin
- type IntID
- type Mutator
- type NotifyMixin
- type Query
- type SnowFlakeID
- type SoftDeleteMixin
- type TenantMixin
Constants ¶
This section is empty.
Variables ¶
var (
EntCoAnnotationName = "EntCo"
)
var (
FieldTenantID = "tenant_id"
)
Functions ¶
func GetTenantRules ¶
GetTenantRules returns the tenant resource conditions for the current user. if field rule is not has value after "/", it will be ignore, and like * effect.
func SkipSoftDelete ¶
SkipSoftDelete returns a new context that skips the soft-delete interceptor/mutators.
Types ¶
type Annotation ¶
type Annotation struct { // Resources is the list of resources that this annotation is applied to. // each resource name use field name Resources []string `json:"Resources,omitempty"` // TenantField is the name of the tenant field.if you want to use a name except tenant_id TenantField string `json:"TenantField,omitempty"` }
Annotation is a schema annotation for Knockout projects.
func Resources ¶
func Resources(fields []string) Annotation
Resources returns a new annotation with the given resources.
func TenantField ¶
func TenantField(field string) Annotation
TenantField returns a new annotation with the given tenant field.
func (Annotation) Merge ¶
func (a Annotation) Merge(other schema.Annotation) schema.Annotation
func (Annotation) Name ¶
func (Annotation) Name() string
type AuditMixin ¶
func (AuditMixin) Fields ¶
func (e AuditMixin) Fields() []ent.Field
func (AuditMixin) Hooks ¶
func (AuditMixin) Hooks() []ent.Hook
type NotifyMixin ¶
NotifyMixin helps to notify when data changed.
func (NotifyMixin) Hooks ¶
func (NotifyMixin) Hooks() []ent.Hook
type SnowFlakeID ¶
type SnowFlakeID struct { // ID is the unique identifier of the user in the database. mixin.Schema }
SnowFlakeID 是采用雪花算法生成的ID.
func (SnowFlakeID) Fields ¶
func (id SnowFlakeID) Fields() []ent.Field
func (SnowFlakeID) SchemaType ¶
func (SnowFlakeID) SchemaType() map[string]string
type SoftDeleteMixin ¶
type SoftDeleteMixin[T Query, Q Mutator] struct { mixin.Schema QueryFunc func(ent.Query) (T, error) }
SoftDeleteMixin implements the soft delete pattern for schemas.
func NewSoftDeleteMixin ¶
func (SoftDeleteMixin[T, Q]) Fields ¶
func (SoftDeleteMixin[T, Q]) Fields() []ent.Field
Fields of the SoftDeleteMixin.
func (SoftDeleteMixin[T, Q]) Hooks ¶
func (d SoftDeleteMixin[T, Q]) Hooks() []ent.Hook
Hooks of the SoftDeleteMixin.
func (SoftDeleteMixin[T, Q]) Interceptors ¶
func (d SoftDeleteMixin[T, Q]) Interceptors() []ent.Interceptor
Interceptors of the SoftDeleteMixin.
func (SoftDeleteMixin[T, Q]) P ¶
func (d SoftDeleteMixin[T, Q]) P(w Query)
P adds a storage-level predicate to the queries and mutations.
type TenantMixin ¶
TenantMixin helps to generate a tenant_id field and inject resource query.
type World struct { ent.Schema } func (World) Mixin() []ent.Mixin { return []ent.Mixin{ schemax.Tenant{}, } }
func NewTenantMixin ¶
func (TenantMixin[T, Q]) Fields ¶
func (TenantMixin[T, Q]) Fields() []ent.Field
func (TenantMixin[T, Q]) Hooks ¶
func (d TenantMixin[T, Q]) Hooks() []ent.Hook
Hooks of the SoftDeleteMixin.
func (TenantMixin[T, Q]) Interceptors ¶
func (d TenantMixin[T, Q]) Interceptors() []ent.Interceptor
Interceptors of the SoftDeleteMixin.
func (TenantMixin[T, Q]) P ¶
func (d TenantMixin[T, Q]) P(w Query, tid int)
P adds a storage-level predicate to the queries and mutations.
func (TenantMixin[T, Q]) QueryRulesP ¶
func (d TenantMixin[T, Q]) QueryRulesP(ctx context.Context, w Query) error