hoophq / sequence

Immutable, scalable, and easy to use ledger service.
Apache License 2.0
492 stars 31 forks source link

Metadata not returning on transactions #9

Open lnmunhoz opened 4 years ago

lnmunhoz commented 4 years ago

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
    }]
    }
  2. 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 commented 4 years ago

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

andriosrobert commented 4 years ago

@lnmunhoz solved in #12

andriosrobert commented 4 years ago

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?

lgrkvst commented 4 years ago

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" 😅 ...)