Add docs for addReduce function
Signed-off-by: David Arendsen <darendsen@gamepoint.com>
This commit is contained in:
parent
7a70c361c9
commit
ea21f35c9c
2 changed files with 67 additions and 2 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
On this page you will find the methods you can use in the query builder.
|
On this page you will find the methods you can use in the query builder.
|
||||||
|
|
||||||
* [from()](functions/from.md)
|
* [from()](functions/from.md)
|
||||||
* [fromBucket()](functions/fromBucket.md)
|
or [fromBucket()](functions/fromBucket.md)
|
||||||
* [fromMeasurement()](functions/fromMeasurement.md)
|
* [fromMeasurement()](functions/fromMeasurement.md)
|
||||||
* [addAggregateWindow()](functions/addAggregateWindow.md)
|
* [addAggregateWindow()](functions/addAggregateWindow.md)
|
||||||
* [addDuplicate()](functions/addDuplicate.md)
|
* [addDuplicate()](functions/addDuplicate.md)
|
||||||
|
|
@ -13,5 +13,8 @@ On this page you will find the methods you can use in the query builder.
|
||||||
* [addLimit()](functions/addLimit.md)
|
* [addLimit()](functions/addLimit.md)
|
||||||
* [addMean()](functions/addMean.md)
|
* [addMean()](functions/addMean.md)
|
||||||
* [addRangeStart()](functions/addRangeStart.md)
|
* [addRangeStart()](functions/addRangeStart.md)
|
||||||
* [addRangeInBetween()](functions/addRangeInBetween.md)
|
or [addRangeInBetween()](functions/addRangeInBetween.md)
|
||||||
|
* [addReduce()](functions/addReduce.md)
|
||||||
|
|
||||||
|
Anything missing here? You can use this method to add anything to the query:
|
||||||
* [addRawFunction()](functions/addRawFunction.md)
|
* [addRawFunction()](functions/addRawFunction.md)
|
||||||
62
docs/functions/addReduce.md
Normal file
62
docs/functions/addReduce.md
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
# Flux Query Builder Docs
|
||||||
|
|
||||||
|
## Functions » addReduce()
|
||||||
|
|
||||||
|
### Parameters:
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Required</th>
|
||||||
|
<th>Data type</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>settings</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>array</td>
|
||||||
|
<td>
|
||||||
|
Reducer calculation to apply to each row record.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>identity</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>array</td>
|
||||||
|
<td>Record that defines the reducer record and provides initial values for the reducer operation on the first row.</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Arendsen\FluxQueryBuilder\Type\MathType;
|
||||||
|
```
|
||||||
|
|
||||||
|
```php
|
||||||
|
->addReduce([
|
||||||
|
[
|
||||||
|
'count' => new MathType('accumulator.count + 1'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'count' => 0,
|
||||||
|
]
|
||||||
|
])
|
||||||
|
```
|
||||||
|
|
||||||
|
This will result in the following Flux function part:
|
||||||
|
|
||||||
|
```
|
||||||
|
|> reduce(fn: (r, accumulator) => ({
|
||||||
|
sum: r._value + accumulator.sum
|
||||||
|
}),
|
||||||
|
identity: {sum: 0}
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Extra resources
|
||||||
|
|
||||||
|
* [Flux documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/reduce/)
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue