GetStore retrieves the details of a specific store using its storeID.
(ctx context.Context, id string)
| 1028 | |
| 1029 | // GetStore retrieves the details of a specific store using its storeID. |
| 1030 | func (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. |
| 1065 | func (s *Datastore) ListStores(ctx context.Context, options storage.ListStoresOptions) ([]*openfgav1.Store, string, error) { |
nothing calls this directly
no test coverage detected