Flux query builder for PHP.
Find a file
davidarendsen 3a112f4e79 Throw Exception if the required functions are defined in incorrect order
Signed-off-by: davidarendsen <davidarendsen@hey.com>
2022-09-01 15:17:25 +00:00
src Throw Exception if the required functions are defined in incorrect order 2022-09-01 15:17:25 +00:00
tests Throw Exception if the required functions are defined in incorrect order 2022-09-01 15:17:25 +00:00
.gitignore Add Flux from() and filter() methods 2022-08-05 15:41:38 +00:00
composer.json Add composer scripts 2022-08-31 08:19:19 +00:00
composer.lock Add composer scripts 2022-08-31 08:19:19 +00:00
phpunit.xml Add Flux from() and filter() methods 2022-08-05 15:41:38 +00:00
README.md Throw Exception if the required functions are defined in incorrect order 2022-09-01 15:17:25 +00:00

InfluxDB 2.x Flux Query Builder

With this query builder you can build queries for Flux. See https://docs.influxdata.com/influxdb/v2.3/query-data/flux/

Installation

composer require arendsen/fluxquerybuilder

Example usage

<?php

use Arendsen\FluxQueryBuilder\QueryBuilder;
use Arendsen\FluxQueryBuilder\Expression\KeyValue;

$queryBuilder = new QueryBuilder();
$queryBuilder->fromBucket('test_bucket')
    ->addRangeStart(new DateTime('3 hours ago'))
    ->fromMeasurement('test_measurement')
    ->addFilter(
        KeyValue::setEqualTo('_field', 'username')
            ->orEqualTo('_field', 'email')
    )
    ->addMap('r with name: r.user')
    ->addGroup(['_field', 'ip']);

echo $queryBuilder->build();

Testing

composer test

Coding style

Run the following commands to check and fix the coding style. We're using the PSR12 standard.

composer check
composer format