MCPcopy Create free account
hub / github.com/Permify/permify / FilterAttributesQuery

Function FilterAttributesQuery

internal/storage/memory/utils/filter.go:40–58  ·  view source on GitHub ↗

FilterAttributesQuery - Filter attributes according to given filter

(tenantID string, filter *base.AttributeFilter)

Source from the content-addressed store, hash-verified

38
39// FilterAttributesQuery - Filter attributes according to given filter
40func FilterAttributesQuery(tenantID string, filter *base.AttributeFilter) memdb.FilterFunc {
41 return func(attributeRaw interface{}) bool {
42 attribute, ok := attributeRaw.(storage.Attribute)
43 if !ok {
44 return true
45 }
46 switch {
47 case attribute.TenantID != tenantID:
48 return true
49 case filter.GetEntity().GetType() != "" && attribute.EntityType != filter.GetEntity().GetType():
50 return true
51 case len(filter.GetEntity().GetIds()) > 0 && !slices.Contains(filter.GetEntity().GetIds(), attribute.EntityID):
52 return true
53 case len(filter.GetAttributes()) > 0 && !slices.Contains(filter.GetAttributes(), attribute.Attribute):
54 return true
55 }
56 return false
57 }
58}

Callers 5

QuerySingleAttributeMethod · 0.92
QueryAttributesMethod · 0.92
ReadAttributesMethod · 0.92
DeleteMethod · 0.92
runOperationMethod · 0.92

Calls 4

GetTypeMethod · 0.65
GetEntityMethod · 0.45
GetIdsMethod · 0.45
GetAttributesMethod · 0.45

Tested by

no test coverage detected