Add collection.keys() to list the keys in the data collection
ben-pr-p opened this issue · comments
Hey there –
Would it be possible to get a collection.keys()
method that listed the keys I've set via @fly.data
? Right now I only see del
, get
, put
, and deleteCollection
. I could make a separate entry that lists the keys as a JSON encoded array, but I'd prefer not to store all of that!
Thanks for all your hard work!
That's a good idea!
@ben-pr-p There is an old pre-release version of this in the data-getall
branch, but it will only work for local dev.
The nature of these kinds of ops means we have to limit what it can return. We can't scan and return an abitrary number of keys until we get support for cursors in, so getAll(prefix)
will only return 100 or so right now. We could pretty easily support getAll(prefix, startAt)
to let you page through things without a cursor, however.
If you want to help out with that branch, a PR would be awesome. These are the places that need to change:
- Data store: https://github.com/superfly/fly/blob/master/packages/core/src/data_store.ts
- sqlite adapter: https://github.com/superfly/fly/blob/master/packages/core/src/sqlite_data_store.ts
- v8env API: https://github.com/superfly/fly/blob/master/packages/v8env/src/fly/data.ts
Most of the changes in the data-getall
branch should be easy to move over: https://github.com/superfly/fly/tree/data-getall