superfly / fly

Deploy app servers close to your users. Package your app as a Docker image, and launch it in 17 cities with one simple CLI.
https://fly.io
985 stars 48 forks source link

Add collection.keys() to list the keys in the data collection #211

Closed ben-pr-p closed 4 years ago

ben-pr-p commented 5 years ago

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!

jeromegn commented 5 years ago

That's a good idea!

mrkurt commented 5 years ago

@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:

Most of the changes in the data-getall branch should be easy to move over: https://github.com/superfly/fly/tree/data-getall