orbit-db-kvstore icon indicating copy to clipboard operation
orbit-db-kvstore copied to clipboard

Interface-datastore compliance

Open vaultec81 opened this issue 4 years ago • 0 comments

What this PR adds

  • Query() method as diagrammed in interface-datastore
  • Batch() method as diagrammed in interface-datastore
  • Has() method as diagrammed in interface-datastore
  • Backwards compatible support for interface-datastore Key Object. (Open to additional discussion).

What this PR does not add

  • Async compliance
  • Method naming compliance (ex del)

Reasoning

Adding the query method is absolutely necessary for applications developers wanting to query key-values with or without a particular prefix. There is currently no API in kvstore that does anything similar. Discovering keys or routinely processing the entire store is not possible with the current API. However, there is an in memory index that can be queried no different than a normal javascript object. This works! But there is no guarantee that the same logic can be provided with different indexes down the road. Using a disk backed index cannot provide the same level of access for example.

I believe adding batch method is necessary for future changes. For example supporting modifying multiple key-value records inside a single oplog entry. Currently batch method commits modifications in multiple oplog entries, this is left open to future implementation modifications supporting multi key-value modification inside a single oplog entry.

By having a solid, well established common interface providing the same API level functionality regardless of implementation, I believe is key to long term utilization

I am open to further discussion on implementation, or alternative approaches.

vaultec81 avatar Mar 21 '20 02:03 vaultec81