UpdateLedgerMetadata updates the metadata for a specific ledger in the database. It marshals the metadata map to JSON before storing it. Parameters: - id: The ID of the ledger to update. - metadata: The new metadata to store. Returns: - error: An error if the update operation fails.
(id string, metadata map[string]interface{})
| 15 | // Returns: |
| 16 | // - error: An error if the update operation fails. |
| 17 | func (d *Datasource) UpdateLedgerMetadata(id string, metadata map[string]interface{}) error { |
| 18 | metadataJSON, err := json.Marshal(metadata) |
| 19 | if err != nil { |
| 20 | return err |
| 21 | } |
| 22 | |
| 23 | _, err = d.Conn.ExecContext(context.Background(), ` |
| 24 | UPDATE ledgerforge.ledgers |
| 25 | SET meta_data = $1 |
| 26 | WHERE ledger_id = $2 |
| 27 | `, metadataJSON, id) |
| 28 | return err |
| 29 | } |
| 30 | |
| 31 | // UpdateTransactionMetadata updates the metadata for a specific transaction in the database. |
| 32 | // It merges the provided metadata with existing metadata for each matching transaction. |
no outgoing calls