Constructor
new TreeIndexer(root)
Create a TreeIndexer.
Parameters
-
root
LogicConceptThe document LC that this indexes
Source
Methods
define(key, options)
Define a new index.
Parameters
-
key
stringUnique key for the index.
-
options
ObjectConfiguration options for the index.
Properties
-
selector
function<optional>
Function to decide if a node matches the index.
-
transform
function<optional>
Function to transform the matching node's value.
-
type
'Array'|'Set'<optional>
Whether to store results in an Array or Set.
-
order
'Depth'|'Post'<optional>
Tree traversal order to use.
-
selector
Source
delete(…keys)
Delete one or more index cache entries. If no keys are given, clears the entire cache.
Parameters
-
keys
string<repeatable>
The index keys to delete.
Source
get(key) → {Array|Set}
Retrieve all indexed values for a specific key, using cached data if available. Triggers a fresh update if the cache is empty.
Parameters
-
key
stringThe index key.
Returns
-
ArraySetThe set or array of indexed values.
Source
show()
Print a string representation of the current cache state. Intended for debugging or inspection in Lode. It doesn't actually return a string.
Source
update(key) → {Array|Set}
Traverse the tree and update the cache for a single index key.
Parameters
-
key
stringThe index key to update.
Returns
-
ArraySetThe result of the index computation.
Throws
Will throw an error if the key is not defined.
Source
updateAll()
Update all indexes, traversing the tree only once per order type. Clears and rebuilds the entire cache.