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

Method UpdateTransactionMetadata

database/metadata.go:43–56  ·  view source on GitHub ↗

UpdateTransactionMetadata updates the metadata for a specific transaction in the database. It merges the provided metadata with existing metadata for each matching transaction. The update applies to both the transaction with the provided ID and any transactions where this ID is set as the parent_tra

(ctx context.Context, id string, metadata map[string]interface{})

Source from the content-addressed store, hash-verified

41// Returns:
42// - error: An error if the update operation fails.
43func (d *Datasource) UpdateTransactionMetadata(ctx context.Context, id string, metadata map[string]interface{}) error {
44 metadataJSON, err := json.Marshal(metadata)
45 if err != nil {
46 return err
47 }
48
49 // Use jsonb_set or similar postgres function to merge the metadata rather than replacing it
50 _, err = d.Conn.ExecContext(ctx, `
51 UPDATE ledgerforge.transactions
52 SET meta_data = meta_data || $1::jsonb
53 WHERE transaction_id = $2 OR parent_transaction = $2
54 `, metadataJSON, id)
55 return err
56}
57
58// UpdateBalanceMetadata updates the metadata for a specific balance in the database.
59// It marshals the metadata map to JSON before storing it.

Callers 1

Calls

no outgoing calls

Tested by 1