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

Function GetEntityByName

internal/schema/schema.go:89–97  ·  view source on GitHub ↗

GetEntityByName retrieves an `EntityDefinition` from a `SchemaDefinition` by its name. It returns a pointer to the `EntityDefinition` if it is found in the `SchemaDefinition`. If the `EntityDefinition` is not found, it returns an error with error code `ERROR_CODE_ENTITY_DEFINITION_NOT_FOUND`.

(schema *base.SchemaDefinition, name string)

Source from the content-addressed store, hash-verified

87// It returns a pointer to the `EntityDefinition` if it is found in the `SchemaDefinition`.
88// If the `EntityDefinition` is not found, it returns an error with error code `ERROR_CODE_ENTITY_DEFINITION_NOT_FOUND`.
89func GetEntityByName(schema *base.SchemaDefinition, name string) (entityDefinition *base.EntityDefinition, err error) {
90 // Look up the entity definition in the schema definition's EntityDefinitions map
91 if en, ok := schema.GetEntityDefinitions()[name]; ok {
92 // If the entity definition is found, return it and a nil error
93 return en, nil
94 }
95 // If the entity definition is not found, return a nil entity definition and an error
96 return nil, errors.New(base.ErrorCode_ERROR_CODE_ENTITY_DEFINITION_NOT_FOUND.String())
97}
98
99// GetRuleByName retrieves the rule definition from the given schema by its name.
100// It takes a pointer to a base.SchemaDefinition and the name of the rule to look for.

Callers 4

addEdgeFromRelationMethod · 0.92
ReadEntityDefinitionMethod · 0.92
ReadEntityDefinitionMethod · 0.92
schema_test.goFile · 0.85

Calls 2

GetEntityDefinitionsMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected