acid
acid copied to clipboard
Better core interface
Consider:
Introduce new Range type composed of something like {store, prefix, mapper}
Range has:
prefix(tup) -> subrange
range(lo, hi, include=True) -> subrange
get(tup, reverse=False) -> fetch prefix+tuple
find(tup, reverse=False) -> fetch prefix+tuple
keys(reverse=False) -> iter
values(reverse=False) -> iter
items(reverse=False) -> iter, alias `__iter__`
delete_all()
Collection is subtype of Range? Otherwise Collection has:
prefix(tup) -> subrange
range(lo, hi, include) -> subrange
all() -> range covering full collection
get(tup) -> all().get(tup)
find(tup, reverse=False) -> all().find(tup, reverse)
Index is subtype of Range? If so, then add extra methods:
override keys() -> first tuple from physical key only
override values() -> map to collection.get(phys_key[1])
The same API should work for meta. Supporting a batch range(lo=, hi=).delete() should optionally cause individual events to fire for the models
prefix() should support:
prefix(..., substr=..., include=...)
Where 'substr' governs whether if the tuple's rightmost element is a string, it is terminated ("string prefix search" vs "children of this key whose last element happens to be a string"). If include is False, then any key matching exactly the prefix is excluded, to allow easy child queries.