Add functions docs page

Signed-off-by: davidarendsen <davidarendsen@hey.com>
This commit is contained in:
davidarendsen 2022-12-30 10:47:44 +00:00
commit cecee3d307
4 changed files with 83 additions and 4 deletions

View file

@ -5,6 +5,7 @@ Welcome to the documentation of the PHP Flux Query Builder.
* [Getting started](01-getting-started.md)
* [InfluxDB concepts](02-what-is-influxdb.md)
* [What is Flux?](03-what-is-flux.md)
* [Functions](04-functions.md)
* [Official InfluxDB documentation](https://docs.influxdata.com/influxdb/v2.6/query-data/flux/)

View file

@ -21,8 +21,8 @@ $queryBuilder->fromBucket('test_bucket')
->fromMeasurement('test_measurement')
->addFieldFilter(['username', 'email'])
->addKeyFilter(
KeyFilter::setEqualTo('_field', 'username')
->orEqualTo('_field', 'email')
KeyFilter::setEqualTo('username', 'David')
->andEqualTo('email', 'david@example.com')
)
->limit(50, 100);
@ -39,7 +39,9 @@ from(bucket: "test_bucket")
r._field == "username" or r._field == "email"
)
|> filter(fn: (r) =>
r._field == "username" or r._field == "email"
r.username == "David" and r.email == "david@example.com"
)
|> limit(n: 50, offset: 100)
```
```
For a deeper dive into the possible methods of the Query builder you can check [this page](04-functions.md).

73
docs/04-functions.md Normal file
View file

@ -0,0 +1,73 @@
# Flux Query Builder Docs
## Functions
On this page you will find the methods you can use in the query builder.
### addAggregateWindow()
**Parameters:**
<table>
<tbody>
<tr>
<th>Name</th>
<th>Data type</th>
<th>Description</th>
<th>Example</th>
</tr>
<tr>
<td>every</td>
<td>string</td>
<td>Duration of time between windows.</td>
<td>20s</td>
</tr>
<tr>
<td>fn</td>
<td>string</td>
<td>Aggregate or selector function to apply to each time window.</td>
<td>mean</td>
</tr>
<tr>
<td>options</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>
column (string): <i>Column to operate on.</i>
</li>
<li>
timeSrc (string): <i>Column to use as the source of the new time value for aggregate values. Default is '_stop'.</i>
</li>
<li>
timeDst (string): <i>Column to store time values for aggregate values in. Default is '_time'.</i>
</li>
<li>
createEmpty (boolean): <i>Create empty tables for empty window. Default is true.</i>
</li>
</ul>
</td>
<td>
<ul>
<li>period: <i>'every'</i></li>
<li>offset: <i>'2s'</i></li>
<li>location: <i>'location'</i></li>
<li>column: <i>'_value'</i></li>
<li>timeSrc: <i>'_stop'</i></li>
<li>timeDst: <i>'_time'</i></li>
<li>createEmpty: <i>false</i></li>
</ul>
</td>
</tr>
</tbody>
</table>