acid icon indicating copy to clipboard operation
acid copied to clipboard

Better core interface

Open dw opened this issue 11 years ago • 2 comments

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])

dw avatar Aug 11 '13 00:08 dw

The same API should work for meta. Supporting a batch range(lo=, hi=).delete() should optionally cause individual events to fire for the models

dw avatar Oct 18 '13 01:10 dw

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.

dw avatar Oct 18 '13 02:10 dw