A PrefixTree is a transparent layer on top of a (scoped) baseClient. It allows you to write as many documents as you want (tested up to about 20,000) without using any slashes in their paths. So basically it’s then a key-value store, and it will “feel” like these documents are all in the base folder. In reality, PrefixTree creates a folder tree based on key prefixes, and translates keyToPath when going from your module code to the baseClient, and pathToKey when coming back from the baseClient to your module (e.g. in change events).
To use it, simply construct it from a BaseClient, for instance the privateClient which you receive when calling defineModule:
var prefixTree = new PrefixTree(privClient);
Then, you can replace all the calls you would usually do to the privClient, and do them to the prefixTree instead. storeObject/getObject, storeFile/getFile, remove, and on are all available. getListing and getAll are not, because they operate on folders, and PrefixTree exposes a non-hierarchical key-value store.
To receive one change event for each item currently in the store (e.g. to populate an in-memory representation), you can call:
|PrefixTree||A PrefixTree is a transparent layer on top of a (scoped) baseClient. |
|setMaxLeaves||Control the internal maxLeaves variable. |
|getFile||The equivalent of BaseClient.getFile|
|storeFile||The equivalent of BaseClient.storeFile|
|getObject||The equivalent of BaseClient.getObject|
|remove||The equivalent of BaseClient.remove|
|storeObject||The equivalent of BaseClient.storeObject|
|on||The equivalent of BaseClient.on|
|fireInitial||Will trigger one change event for each document currently in the tree. |