khonsulabs / bonsaidb

A developer-friendly document database that grows with you, written in Rust
https://bonsaidb.io/
Apache License 2.0
1.01k stars 37 forks source link

Add easier API to List with a Prefix #210

Closed ecton closed 2 years ago

ecton commented 2 years ago

Some types have a logical idea of what a "starts_with" match would evaluate to. Today, it's possible to manually construct a range that can be passed into list() or with_key_range() that perform the same function. For example, to scan a byte range that starts with the prefix [0, 0], you would issue a db.collection::<MyCollection>().list([0,0]..[0,1]).await.

It would be nice to offer a way for types that support it to offer a way to create these ranges easily.

ecton commented 2 years ago

Added in 2acbded98073fe0c61055d2063a63a58184ebb8a