Dynamic
Description
Dynamic selectors allow you to select items from lists or maps when you don't know the key or index. You can think of this as searching the current node.
Usage
You can use a selector as the key to create more complex conditions.
Key
The key defines which property/selector we should use to extract a value.
If <key>
is:
.
orvalue
- dasel checks if the current nodes value is<value>
.-
orkeyValue
- dasel checks if the key/name/index of the current node is<value>
.Else dasel uses the key as a selector itself and compares the result against
<value>
.
Value
The value is the expected value for the check to pass.
Note that dasel will stringy values prior to checking if they match.
Comparisons
Dasel supports the following comparison operators:
Multiple conditions
You can use multiple dynamic selectors within the same part to perform AND
logic.
Non-object values
You can evaluate and check against non-object values by defining the key
as either value
or .
. Doing so will tell dasel extract the value of the current node and compare that against <value>
.
Selectors as a key
When performing dynamic checks dasel internally creates a new root node at the current position and queries data from there.
This means that you can use fully formed selectors as a key to create more advanced logic.
The above selector in plain English may read as...
Give me the first name of the user who's primary address is at number 123.
The resolution of that query looks something like this:
Example
Single condition
Multiple conditions
Selector as a key
Last updated