MCPcopy
hub / github.com/openfga/openfga / FindLatestAuthorizationModel

Method FindLatestAuthorizationModel

pkg/storage/postgres/postgres.go:932–956  ·  view source on GitHub ↗

FindLatestAuthorizationModel see [storage.AuthorizationModelReadBackend].FindLatestAuthorizationModel.

(ctx context.Context, store string)

Source from the content-addressed store, hash-verified

930
931// FindLatestAuthorizationModel see [storage.AuthorizationModelReadBackend].FindLatestAuthorizationModel.
932func (s *Datastore) FindLatestAuthorizationModel(ctx context.Context, store string) (*openfgav1.AuthorizationModel, error) {
933 ctx, span := startTrace(ctx, "FindLatestAuthorizationModel")
934 defer span.End()
935
936 db := s.getPgxPool(openfgav1.ConsistencyPreference_MINIMIZE_LATENCY)
937 stmt, args, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar).
938 Select("authorization_model_id", "schema_version", "type", "type_definition", "serialized_protobuf").
939 From("authorization_model").
940 Where(sq.Eq{"store": store}).
941 OrderBy("authorization_model_id desc").ToSql()
942 if err != nil {
943 return nil, HandleSQLError(err)
944 }
945 rows, err := db.Query(ctx, stmt, args...)
946 if err != nil {
947 return nil, HandleSQLError(err)
948 }
949 defer rows.Close()
950 ret, err := sqlcommon.ConstructAuthorizationModelFromSQLRows(&pgxRowsWrapper{rows})
951 if err != nil {
952 return nil, HandleSQLError(err)
953 }
954
955 return ret, nil
956}
957
958// MaxTypesPerAuthorizationModel see [storage.TypeDefinitionWriteBackend].MaxTypesPerAuthorizationModel.
959func (s *Datastore) MaxTypesPerAuthorizationModel() int {

Callers

nothing calls this directly

Calls 9

getPgxPoolMethod · 0.95
startTraceFunction · 0.70
HandleSQLErrorFunction · 0.70
EndMethod · 0.65
ToSqlMethod · 0.65
SelectMethod · 0.65
QueryMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected