findRecord() function
The findRecord()
function returns a record at a specified index from the first
table in a stream of tables where the group key values match the specified predicate.
The function returns an empty record if no table is found or if the index is out of bounds.
findRecord(
fn: (key) => key._field == "fieldName",
idx: 0,
)
Parameters
fn
A predicate function for matching keys in a table’s group key.
Expects a key
argument that represents a group key in the input stream.
idx
Index of the record to extract.
tables
Input data.
Default is piped-forward data (<-
).
Example
The following example uses data provided by the sampledata
package
to show how findRecord()
transforms data.
import "sampledata"
sampledata.int()
|> findRecord(fn: (key) => key.tag == "t1", idx: 0)
// Returns {_time: 2021-01-01T00:00:00.000000000Z, _value: -2, tag: t1}
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, the following resources are available:
InfluxDB Cloud customers can contact InfluxData Support.