libkv icon indicating copy to clipboard operation
libkv copied to clipboard

Request: Non Recursive "directory" listing

Open therealbill opened this issue 10 years ago • 0 comments

While .List(key) is useful if I want everything under the directory/root passed to it, there are some aspects of an ls type action which are very useful but missing:

  1. Non-Recursive Listing or depth specification
  2. What type of children to return

For the first I want to be able to get just the immediate children. For the second I want to be able to get back "directories", "keys", or both. For example something like:

kv.List("foo/bar/","directory",false)

...where false is a flag for recursion, and the return is a list of sub directories in "foo/bar". Alternatively making the second argument "keys" would only return keys, and "any" would return both. Passing true for the third argument would indicate I want all of whatever type under that prefix.

Alternatively we could instead of 'recurse boolwe could use adepthparameter wheredepth=0means no recursion, anddepth=5` means you wild get listing for up to 5 levels down from the given prefix.

Obviously the example would break the existing API so I'd be open to another name such as ListFilter or something ti identify it is a bit stronger than a basic List call

therealbill avatar Dec 18 '15 02:12 therealbill