From 194aed989ca40294feceb283328cd58c3d7f5ff0 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 11 Dec 2020 14:45:13 -0700 Subject: [PATCH] added the dict package --- .../reference/flux/stdlib/dict/_index.md | 15 ++++ .../reference/flux/stdlib/dict/fromlist.md | 13 +++ .../cloud/reference/flux/stdlib/dict/get.md | 13 +++ .../reference/flux/stdlib/dict/insert.md | 14 +++ .../reference/flux/stdlib/dict/remove.md | 13 +++ .../v2.0/reference/flux/stdlib/dict/_index.md | 22 +++++ .../reference/flux/stdlib/dict/fromlist.md | 48 +++++++++++ .../v2.0/reference/flux/stdlib/dict/get.md | 62 ++++++++++++++ .../v2.0/reference/flux/stdlib/dict/insert.md | 85 +++++++++++++++++++ .../v2.0/reference/flux/stdlib/dict/remove.md | 59 +++++++++++++ 10 files changed, 344 insertions(+) create mode 100644 content/influxdb/cloud/reference/flux/stdlib/dict/_index.md create mode 100644 content/influxdb/cloud/reference/flux/stdlib/dict/fromlist.md create mode 100644 content/influxdb/cloud/reference/flux/stdlib/dict/get.md create mode 100644 content/influxdb/cloud/reference/flux/stdlib/dict/insert.md create mode 100644 content/influxdb/cloud/reference/flux/stdlib/dict/remove.md create mode 100644 content/influxdb/v2.0/reference/flux/stdlib/dict/_index.md create mode 100644 content/influxdb/v2.0/reference/flux/stdlib/dict/fromlist.md create mode 100644 content/influxdb/v2.0/reference/flux/stdlib/dict/get.md create mode 100644 content/influxdb/v2.0/reference/flux/stdlib/dict/insert.md create mode 100644 content/influxdb/v2.0/reference/flux/stdlib/dict/remove.md diff --git a/content/influxdb/cloud/reference/flux/stdlib/dict/_index.md b/content/influxdb/cloud/reference/flux/stdlib/dict/_index.md new file mode 100644 index 000000000..9cfe4e55c --- /dev/null +++ b/content/influxdb/cloud/reference/flux/stdlib/dict/_index.md @@ -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 >}} \ No newline at end of file diff --git a/content/influxdb/cloud/reference/flux/stdlib/dict/fromlist.md b/content/influxdb/cloud/reference/flux/stdlib/dict/fromlist.md new file mode 100644 index 000000000..e31b9a6aa --- /dev/null +++ b/content/influxdb/cloud/reference/flux/stdlib/dict/fromlist.md @@ -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 >}} \ No newline at end of file diff --git a/content/influxdb/cloud/reference/flux/stdlib/dict/get.md b/content/influxdb/cloud/reference/flux/stdlib/dict/get.md new file mode 100644 index 000000000..2d3c306e3 --- /dev/null +++ b/content/influxdb/cloud/reference/flux/stdlib/dict/get.md @@ -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 >}} \ No newline at end of file diff --git a/content/influxdb/cloud/reference/flux/stdlib/dict/insert.md b/content/influxdb/cloud/reference/flux/stdlib/dict/insert.md new file mode 100644 index 000000000..e25177cbd --- /dev/null +++ b/content/influxdb/cloud/reference/flux/stdlib/dict/insert.md @@ -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 >}} \ No newline at end of file diff --git a/content/influxdb/cloud/reference/flux/stdlib/dict/remove.md b/content/influxdb/cloud/reference/flux/stdlib/dict/remove.md new file mode 100644 index 000000000..97b0d0b69 --- /dev/null +++ b/content/influxdb/cloud/reference/flux/stdlib/dict/remove.md @@ -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 >}} \ No newline at end of file diff --git a/content/influxdb/v2.0/reference/flux/stdlib/dict/_index.md b/content/influxdb/v2.0/reference/flux/stdlib/dict/_index.md new file mode 100644 index 000000000..92e3e2656 --- /dev/null +++ b/content/influxdb/v2.0/reference/flux/stdlib/dict/_index.md @@ -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" >}} diff --git a/content/influxdb/v2.0/reference/flux/stdlib/dict/fromlist.md b/content/influxdb/v2.0/reference/flux/stdlib/dict/fromlist.md new file mode 100644 index 000000000..1c687891c --- /dev/null +++ b/content/influxdb/v2.0/reference/flux/stdlib/dict/fromlist.md @@ -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 +```` \ No newline at end of file diff --git a/content/influxdb/v2.0/reference/flux/stdlib/dict/get.md b/content/influxdb/v2.0/reference/flux/stdlib/dict/get.md new file mode 100644 index 000000000..5d0714c69 --- /dev/null +++ b/content/influxdb/v2.0/reference/flux/stdlib/dict/get.md @@ -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 + +

+ {{< req "All paremeters are required" >}} +

+ +### 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 +``` \ No newline at end of file diff --git a/content/influxdb/v2.0/reference/flux/stdlib/dict/insert.md b/content/influxdb/v2.0/reference/flux/stdlib/dict/insert.md new file mode 100644 index 000000000..7ec8f9aa9 --- /dev/null +++ b/content/influxdb/v2.0/reference/flux/stdlib/dict/insert.md @@ -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 + +

+ {{< req "All paremeters are required" >}} +

+ +### 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 +``` \ No newline at end of file diff --git a/content/influxdb/v2.0/reference/flux/stdlib/dict/remove.md b/content/influxdb/v2.0/reference/flux/stdlib/dict/remove.md new file mode 100644 index 000000000..0330e993a --- /dev/null +++ b/content/influxdb/v2.0/reference/flux/stdlib/dict/remove.md @@ -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 + +

+ {{< req "All paremeters are required" >}} +

+ +### 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 +```