orbit-db-kvstore
orbit-db-kvstore copied to clipboard
Interface-datastore compliance
What this PR adds
-
Query()
method as diagrammed ininterface-datastore
-
Batch()
method as diagrammed ininterface-datastore
-
Has()
method as diagrammed ininterface-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.