MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / UpdateLedgerMetadata

Method UpdateLedgerMetadata

database/metadata.go:17–29  ·  view source on GitHub ↗

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{})

Source from the content-addressed store, hash-verified

15// Returns:
16// - error: An error if the update operation fails.
17func (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.

Callers 2

TestUpdateLedgerMetadataFunction · 0.95
TestUpdateMetadata_ErrorFunction · 0.95

Calls

no outgoing calls

Tested by 2

TestUpdateLedgerMetadataFunction · 0.76
TestUpdateMetadata_ErrorFunction · 0.76