Documentation

record.get() function

Flux 0.134.0+

The record.get() function is experimental and subject to change at any time. By using this function, you accept the risks of experimental functions.

record.get() returns a value from a record by key name or a default value if the key doesn’t exist in the record.

This is an interim solution for the exists operator’s limited use with records outside of a stream of tables. For more information, see influxdata/flux#4073.

import "experimental/record"

record.get(
  r: {foo, "bar"},
  key: "foo",
  default: "quz"  
)

Parameters

r

(Required) Record to retrieve the value from.

key

(Required) Property key to retrieve

default

(Required) Default value to return if the specified key does not exist in the record.

Examples

Dynamically return a value from a record

import "experimental/record"

key = "foo"
exampleRecord = {foo: 1.0, bar: "hello"}

record.get(
  r: exampleRecord,
  key: key,
  default: ""
)

// Returns 1.0

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.