GetLineageMappingByProvider retrieves a specific lineage mapping for a balance and provider.
(ctx context.Context, balanceID, provider string)
| 93 | |
| 94 | // GetLineageMappingByProvider retrieves a specific lineage mapping for a balance and provider. |
| 95 | func (d Datasource) GetLineageMappingByProvider(ctx context.Context, balanceID, provider string) (*model.LineageMapping, error) { |
| 96 | row := d.Conn.QueryRowContext(ctx, ` |
| 97 | SELECT id, balance_id, provider, shadow_balance_id, aggregate_balance_id, identity_id, created_at |
| 98 | FROM ledgerforge.lineage_mappings |
| 99 | WHERE balance_id = $1 AND provider = $2 |
| 100 | `, balanceID, provider) |
| 101 | |
| 102 | var mapping model.LineageMapping |
| 103 | err := row.Scan( |
| 104 | &mapping.ID, |
| 105 | &mapping.BalanceID, |
| 106 | &mapping.Provider, |
| 107 | &mapping.ShadowBalanceID, |
| 108 | &mapping.AggregateBalanceID, |
| 109 | &mapping.IdentityID, |
| 110 | &mapping.CreatedAt, |
| 111 | ) |
| 112 | if err != nil { |
| 113 | if err == sql.ErrNoRows { |
| 114 | return nil, nil |
| 115 | } |
| 116 | return nil, apierror.NewAPIError(apierror.ErrInternalServer, "Failed to retrieve lineage mapping", err) |
| 117 | } |
| 118 | |
| 119 | return &mapping, nil |
| 120 | } |
| 121 | |
| 122 | // DeleteLineageMapping deletes a lineage mapping by its ID. |
| 123 | func (d Datasource) DeleteLineageMapping(ctx context.Context, id int64) error { |
nothing calls this directly
no test coverage detected