node-foundationdb
node-foundationdb copied to clipboard
Added support for including keyspace ends in the ranges
I've implemented a concept solution for #78. I think this is the best option, ie least bloat for the maximum robustness. The implementation hasn't been tested and needs more documentation. I'm interested in any feedback.
The PR does the following:
- Add
StartsWithvariants for all methods that deal with ranges. Those are what developers should use to get the prefix behavior. The original methods continue work as before by default. - Modify
Subspace#packRangeto deal withstart/endcombinations. AddSubspace#packRangeStartsWithfor handling prefixes. Like before, the later is what developers should use for prefix behavior but the original one stays backwards compatible by default. - Make all packing/unpacking go through
Subspace, so that there's only one central place for all that complexity. While packing/unpacking individual keys/values doesn't strictly need to go through subspace, there's now less reason to keep the transformer copies around. Maybe it should be a separate commit. - Add
_noDefaultPrefixflag to subspace andSubspace#noDefaultPrefixandDatabase#noDefaultPrefixmethods. These switch the subspace to a mode that enables including key space ends in the ranges. The naming of these could be improved. - Make end key default to subspace end in the
noDefaultPrefixmode. - Make start key optional, defaulting to subspace start. This is good for consistency but also useful for abstractions that want to specify the range in an encoding agnostic way but still benefit from automatic key encoding/decoding and type safety.