Add documentation about addMap, addSort, addUnwindow, and addWindow

Signed-off-by: David Arendsen <darendsen@gamepoint.com>
This commit is contained in:
David Arendsen 2023-02-11 17:33:35 +01:00
commit b7e0b21c8f
9 changed files with 179 additions and 27 deletions

View file

@ -0,0 +1,39 @@
# Flux Query Builder Docs
## Functions &raquo; addMap()
### Parameters:
<table>
<tbody>
<tr>
<th>Name</th>
<th>Required</th>
<th>Data type</th>
<th>Description</th>
</tr>
<tr>
<td>fn</td>
<td>Yes</td>
<td>string</td>
<td>Single argument function to apply to each record. The return value must be a record.</td>
</tr>
</tbody>
</table>
### Example
```php
->addMap('r with name: r.user')
```
This will result in the following Flux function part:
```
|> map(fn: (r) => ({ r with name: r.user }))
```
### Extra resources
* [Flux documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/map/)

View file

@ -0,0 +1,39 @@
# Flux Query Builder Docs
## Functions &raquo; addSort()
### Parameters:
<table>
<tbody>
<tr>
<th>Name</th>
<th>Required</th>
<th>Data type</th>
<th>Description</th>
</tr>
<tr>
<td>columns</td>
<td>Yes</td>
<td>array</td>
<td>List of columns to sort by. Default is ["_value"].</td>
</tr>
</tbody>
</table>
### Example
```php
->addSort(['column1', 'column2'], true)
```
This will result in the following Flux function part:
```
|> sort(columns: ["column1", "column2"], desc: true)
```
### Extra resources
* [Flux documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/sort/)

View file

@ -0,0 +1,21 @@
# Flux Query Builder Docs
## Functions &raquo; addUnwindow()
Keeping aggregate values in separate tables generally isnt the format in which you want your data. Use the window() function to “unwindow” your data into a single infinite (inf) window.
### Example
```php
->addUnwindow()
```
This will result in the following Flux function part:
```
|> window(every: inf)
```
### Extra resources
* [Flux documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/window/)

View file

@ -0,0 +1,71 @@
# Flux Query Builder Docs
## Functions &raquo; addWindow()
### Parameters:
<table>
<tbody>
<tr>
<th>Name</th>
<th>Required</th>
<th>Data type</th>
<th>Description</th>
</tr>
<tr>
<td>every</td>
<td>Yes</td>
<td>string</td>
<td>Duration of time between windows.</td>
</tr>
<tr>
<td>options</td>
<td>No</td>
<td>array</td>
<td>
<ul>
<li>
period (string): <i>Duration of windows. Default is the 'every' value.</i>
</li>
<li>
offset (string): <i>Duration to shift the window boundaries by. Default is '0s'.</i>
</li>
<li>
location (string): <i>Location used to determine timezone. Default is the 'location' option.</i>
</li>
<li>
timeColumn (string): <i>Column that contains time values. Default is '_time'.</i>
</li>
<li>
startColumn (string): <i>Column to store the window start time in. Default is '_start'.</i>
</li>
<li>
stopColumn (string): <i>Column to store the window stop time in. Default is '_stop'.</i>
</li>
<li>
createEmpty (boolean): <i>Create empty tables for empty window. Default is false.</i>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
### Example
```php
->addWindow('20s', [
'timeColumn' => '_time',
])
```
This will result in the following Flux function part:
```
|> window(every: 20s, timeColumn: "_time")
```
### Extra resources
* [Flux documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/window/)