added the dict package
parent
6acf9857c8
commit
194aed989c
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: Flux Dictionary package
|
||||
list_title: Dictionary package
|
||||
description: >
|
||||
The Flux dictionary package provides functions for interacting with dictionary types.
|
||||
Import the `dict` package.
|
||||
menu:
|
||||
influxdb_cloud_ref:
|
||||
name: Dictionary
|
||||
parent: Flux standard library
|
||||
weight: 202
|
||||
influxdb/v2.0/tags: [package, functions]
|
||||
---
|
||||
|
||||
{{< duplicate-oss >}}
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: dict.fromList() function
|
||||
description: >
|
||||
The `dict.fromList()` function creates a dictionary from a list of records with
|
||||
`key` and `value` properties.
|
||||
menu:
|
||||
influxdb_cloud_ref:
|
||||
name: dict.fromList
|
||||
parent: Dictionary
|
||||
weight: 301
|
||||
---
|
||||
|
||||
{{< duplicate-oss >}}
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: dict.get() function
|
||||
description: >
|
||||
The `dict.get()` function returns the value of a specified key in a dictionary
|
||||
or a default value if the key does not exist.
|
||||
menu:
|
||||
influxdb_cloud_ref:
|
||||
name: dict.get
|
||||
parent: Dictionary
|
||||
weight: 301
|
||||
---
|
||||
|
||||
{{< duplicate-oss >}}
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
title: dict.insert() function
|
||||
description: >
|
||||
The `dict.insert()` function inserts a key value pair into a dictionary and
|
||||
returns a new, updated dictionary.
|
||||
If the key already exists in the dictionary, the function overwrites the existing value.
|
||||
menu:
|
||||
influxdb_cloud_ref:
|
||||
name: dict.insert
|
||||
parent: Dictionary
|
||||
weight: 301
|
||||
---
|
||||
|
||||
{{< duplicate-oss >}}
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: dict.remove() function
|
||||
description: >
|
||||
The `dict.remove()` function removes a key value pair from a dictionary and returns
|
||||
and updated dictionary.
|
||||
menu:
|
||||
influxdb_cloud_ref:
|
||||
name: dict.remove
|
||||
parent: Dictionary
|
||||
weight: 301
|
||||
---
|
||||
|
||||
{{< duplicate-oss >}}
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
title: Flux Dictionary package
|
||||
list_title: Dictionary package
|
||||
description: >
|
||||
The Flux dictionary package provides functions for interacting with dictionary types.
|
||||
Import the `dict` package.
|
||||
menu:
|
||||
influxdb_2_0_ref:
|
||||
name: Dictionary
|
||||
parent: Flux standard library
|
||||
weight: 202
|
||||
influxdb/v2.0/tags: [package, functions]
|
||||
---
|
||||
|
||||
The Flux dictionary package provides functions for interacting with [dictionary types](/influxdb/v2.0/reference/flux/language/types/#dictionary-types).
|
||||
Import the `dict` package.
|
||||
|
||||
```js
|
||||
import "dict"
|
||||
```
|
||||
|
||||
{{< children type="functions" show="pages" >}}
|
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
title: dict.fromList() function
|
||||
description: >
|
||||
The `dict.fromList()` function creates a dictionary from a list of records with
|
||||
`key` and `value` properties.
|
||||
menu:
|
||||
influxdb_2_0_ref:
|
||||
name: dict.fromList
|
||||
parent: Dictionary
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `dict.fromList()` function creates a dictionary from a list of records with
|
||||
`key` and `value` properties.
|
||||
|
||||
```js
|
||||
import "dict"
|
||||
|
||||
dict.fromList(
|
||||
pairs: [
|
||||
{key: 1, value: "foo"},
|
||||
{key: 2, value: "bar"}
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### pairs
|
||||
List of records, each containing `key` and `value` properties.
|
||||
|
||||
_**Data type:** Array of records_
|
||||
|
||||
## Examples
|
||||
```js
|
||||
import "dict"
|
||||
|
||||
d = dict.fromList(
|
||||
pairs: [
|
||||
{key: 1, value: "foo"},
|
||||
{key: 2, value: "bar"}
|
||||
]
|
||||
)
|
||||
|
||||
dict.get(dict: d, key: 1, default: "")
|
||||
|
||||
// Returns foo
|
||||
````
|
|
@ -0,0 +1,62 @@
|
|||
---
|
||||
title: dict.get() function
|
||||
description: >
|
||||
The `dict.get()` function returns the value of a specified key in a dictionary
|
||||
or a default value if the key does not exist.
|
||||
menu:
|
||||
influxdb_2_0_ref:
|
||||
name: dict.get
|
||||
parent: Dictionary
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `dict.get()` function returns the value of a specified key in a dictionary
|
||||
or a default value if the key does not exist.
|
||||
|
||||
```js
|
||||
import "dict"
|
||||
|
||||
dict.get(
|
||||
dict: [1: "foo", 2: "bar"],
|
||||
key: 1,
|
||||
default: ""
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<p>
|
||||
{{< req "All paremeters are required" >}}
|
||||
</p>
|
||||
|
||||
### dict
|
||||
Dictionary to return a value from.
|
||||
|
||||
_**Data type:** Dictionary_
|
||||
|
||||
### key
|
||||
Key to return from the dictionary.
|
||||
|
||||
_**Data type:** String | Boolean | Integer | Uinteger | Float | Time | Bytes_
|
||||
|
||||
### default
|
||||
Default value to return if the `key` does not exist in the dictionary.
|
||||
Must be the same type as values in the dictionary.
|
||||
|
||||
_**Data type:** String | Boolean | Integer | Uinteger | Float | Time | Bytes_
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
import "dict"
|
||||
|
||||
d = [1: "foo", 2: "bar"]
|
||||
|
||||
dict.get(
|
||||
dict: d,
|
||||
key: 1,
|
||||
default: ""
|
||||
)
|
||||
|
||||
// Returns foo
|
||||
```
|
|
@ -0,0 +1,85 @@
|
|||
---
|
||||
title: dict.insert() function
|
||||
description: >
|
||||
The `dict.insert()` function inserts a key value pair into a dictionary and
|
||||
returns a new, updated dictionary.
|
||||
If the key already exists in the dictionary, the function overwrites the existing value.
|
||||
menu:
|
||||
influxdb_2_0_ref:
|
||||
name: dict.insert
|
||||
parent: Dictionary
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `dict.insert()` function inserts a key value pair into a dictionary and returns
|
||||
a new, updated dictionary.
|
||||
If the key already exists in the dictionary, the function overwrites the existing value.
|
||||
|
||||
```js
|
||||
import "dict"
|
||||
|
||||
dict.insert(
|
||||
dict: [1: "foo", 2: "bar"],
|
||||
key: 3,
|
||||
value: "baz"
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<p>
|
||||
{{< req "All paremeters are required" >}}
|
||||
</p>
|
||||
|
||||
### dict
|
||||
Dictionary to update.
|
||||
|
||||
_**Data type:** Dictionary_
|
||||
|
||||
### key
|
||||
Key to insert into the dictionary.
|
||||
Must be the same type as existing keys in the dictionary.
|
||||
|
||||
_**Data type:** String | Boolean | Integer | Uinteger | Float | Time | Bytes_
|
||||
|
||||
### default
|
||||
Value to insert into the dictionary.
|
||||
Must be the same type as existing values in the dictionary.
|
||||
|
||||
_**Data type:** String | Boolean | Integer | Uinteger | Float | Time | Bytes_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Insert a new key-value pair into a dictionary
|
||||
```js
|
||||
import "dict"
|
||||
|
||||
d = [1: "foo", 2: "bar"]
|
||||
|
||||
dNew = dict.insert(
|
||||
dict: d,
|
||||
key: 3,
|
||||
value: "baz"
|
||||
)
|
||||
|
||||
dict.get(dict: dNew, key: 3, default: "")
|
||||
|
||||
// Returns baz
|
||||
```
|
||||
|
||||
##### Overwrite an existing key-value pair in a dictionary
|
||||
```js
|
||||
import "dict"
|
||||
|
||||
d = [1: "foo", 2: "bar"]
|
||||
|
||||
dNew = dict.insert(
|
||||
dict: d,
|
||||
key: 2,
|
||||
value: "baz"
|
||||
)
|
||||
|
||||
dict.get(dict: dNew, key: 2, default: "")
|
||||
|
||||
// Returns baz
|
||||
```
|
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
title: dict.remove() function
|
||||
description: >
|
||||
The `dict.remove()` function removes a key value pair from a dictionary and returns
|
||||
and updated dictionary.
|
||||
menu:
|
||||
influxdb_2_0_ref:
|
||||
name: dict.remove
|
||||
parent: Dictionary
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `dict.remove()` function removes a key value pair from a dictionary and returns
|
||||
and updated dictionary.
|
||||
|
||||
```js
|
||||
import "dict"
|
||||
|
||||
dict.remove(
|
||||
dict: [1: "foo", 2: "bar"],
|
||||
key: 1
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
<p>
|
||||
{{< req "All paremeters are required" >}}
|
||||
</p>
|
||||
|
||||
### dict
|
||||
Dictionary to remove a key-value pair from.
|
||||
|
||||
_**Data type:** Dictionary_
|
||||
|
||||
### key
|
||||
Key to remove from the dictionary.
|
||||
Must be the same type as existing keys in the dictionary.
|
||||
|
||||
_**Data type:** String | Boolean | Integer | Uinteger | Float | Time | Bytes_
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
import "dict"
|
||||
|
||||
d = [1: "foo", 2: "bar"]
|
||||
|
||||
dNew = dict.remove(
|
||||
dict: d,
|
||||
key: 1
|
||||
)
|
||||
|
||||
dict.get(dict: dNew, key: 1, default: "")
|
||||
// Returns an empty string
|
||||
|
||||
dict.get(dict: dNew, key: 2, default: "")
|
||||
// Returns bar
|
||||
```
|
Loading…
Reference in New Issue