MCPcopy
hub / github.com/openfga/openfga / GetStore

Method GetStore

pkg/storage/postgres/postgres.go:1030–1062  ·  view source on GitHub ↗

GetStore retrieves the details of a specific store using its storeID.

(ctx context.Context, id string)

Source from the content-addressed store, hash-verified

1028
1029// GetStore retrieves the details of a specific store using its storeID.
1030func (s *Datastore) GetStore(ctx context.Context, id string) (*openfgav1.Store, error) {
1031 ctx, span := startTrace(ctx, "GetStore")
1032 defer span.End()
1033
1034 db := s.getPgxPool(openfgav1.ConsistencyPreference_MINIMIZE_LATENCY)
1035 stmt, args, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar).
1036 Select("id", "name", "created_at", "updated_at").
1037 From("store").
1038 Where(sq.Eq{
1039 "id": id,
1040 "deleted_at": nil,
1041 }).ToSql()
1042
1043 if err != nil {
1044 return nil, HandleSQLError(err)
1045 }
1046
1047 row := db.QueryRow(ctx, stmt, args...)
1048
1049 var storeID, name string
1050 var createdAt, updatedAt time.Time
1051 err = row.Scan(&storeID, &name, &createdAt, &updatedAt)
1052 if err != nil {
1053 return nil, HandleSQLError(err)
1054 }
1055
1056 return &openfgav1.Store{
1057 Id: storeID,
1058 Name: name,
1059 CreatedAt: timestamppb.New(createdAt),
1060 UpdatedAt: timestamppb.New(updatedAt),
1061 }, nil
1062}
1063
1064// ListStores provides a paginated list of all stores present in the storage.
1065func (s *Datastore) ListStores(ctx context.Context, options storage.ListStoresOptions) ([]*openfgav1.Store, string, error) {

Callers

nothing calls this directly

Calls 7

getPgxPoolMethod · 0.95
startTraceFunction · 0.70
HandleSQLErrorFunction · 0.70
EndMethod · 0.65
ToSqlMethod · 0.65
SelectMethod · 0.65
ScanMethod · 0.65

Tested by

no test coverage detected