sequence icon indicating copy to clipboard operation
sequence copied to clipboard

Metadata not returning on transactions

Open lnmunhoz opened this issue 5 years ago • 4 comments
trafficstars

When creating or fetching transactions, the metadata is not returned.

To reproduce:

  1. Given the transaction created with this payload:
{
    "from": "lucas",
    "to": "andrios",
    "amount": 100,
    "currency": "BRL",
    "metadata": [{
        "test": true
    }]
}
  1. I should get back two transactions with the same metadata, but what I get back does not contain metadata:
[
    {
        "amount": 100,
        "date": "2020-09-12T09:21:23.764Z",
        "currency": "BRL",
        "balance": 500,
        "from": "lucas",
        "id": "16ea0f46389d2511cae81954309a339b",
        "to": "andrios"
    },
    {
        "amount": 100,
        "date": "2020-09-12T09:21:23.767Z",
        "currency": "BRL",
        "balance": 100,
        "from": "lucas",
        "id": "c44eacd2b08586b54b4ab179fdea09af",
        "to": "andrios"
    }
]

lnmunhoz avatar Sep 12 '20 09:09 lnmunhoz

Also, would be nice to query transactions by metadata. Is that something you consider to implement?

lnmunhoz avatar Sep 12 '20 09:09 lnmunhoz

@lnmunhoz solved in #12

andriosrobert avatar Sep 12 '20 20:09 andriosrobert

Also, would be nice to query transactions by metadata. Is that something you consider to implement?

I thought about it, but don't think this is a good idea. Mostly because this is a dynamic field. There is no way we can build an efficient index to be queried on the data if we don't know it. Things like cardinality are very important for indexes.

Can you explain a bit of your use case?

andriosrobert avatar Sep 12 '20 22:09 andriosrobert

The simplest use-case I can think of is merely searching/filtering transactions, e.g. if I consistently store tx messages in metadata["message"], or location of a purchase, if available, in metadata["WGS84"], the use-case would be to filter all transactions that has the tx message walmart.

(The location use-case on the other hand becomes hardcore pretty quickly: "give me all transactions in a 10 km radius around 55.276192,-5.3228631" 😅 ...)

lgrkvst avatar Sep 17 '20 09:09 lgrkvst