EOSIO / EEPs

EOSIO Enhancement Proposals
15 stars 18 forks source link

Multi-index table query with discontinuous keys #10

Closed conr2d closed 3 months ago

conr2d commented 3 years ago

Background

The current design of RPC API /v1/chain/get_table_rows allows querying data with one or consecutive range of keys. If application wants to query data with discontinuous keys, it should send multiple requests to nodeos and results in inconvenience and network overhead.

Proposal

Allow optional field keys in the arguments of /v1/chain/get_table_rows:

{
  "code": "eosio",
  "scope": "eosio",
  "table": "voters",
  "keys": ["alice", "bob", "carol"],
  "lower_bound": "",
  "upper_bound": "",
}

When keys is not an empty array, lower_bound and upper_bound should be an empty string. keys field is optional (can be omitted), so it doesn't break backward compatibility.

Each value will be included in the returned rows when exactly same key exists, but if a non-existent key is included in keys parameter, null is returned for the value at the index of non-existent key.

cf) primary_key bob doesn't exist:

{
  "rows": [
    {
      "owner": "alice",
      "proxy": "eosproxy1",
      "producers": []
    },
    null,
    {
      "owner": "carol",
      "proxy": "",
      "producers": ["eosbp1", "eosbp2"]
    }
  ],
  "more": null
}

Implementation

turnpike/eos@4e6dd13ee00f98374800251b3b23f31be4dd6ecc

prasety4s commented 2 years ago

helooo

prasety4s commented 2 years ago

helooo