Flux query builder for PHP.
Find a file
davidarendsen c66b71ee57 Add KeyFilter and deprecate KeyValue object
Signed-off-by: davidarendsen <davidarendsen@hey.com>
2022-10-21 20:03:52 +00:00
src Add KeyFilter and deprecate KeyValue object 2022-10-21 20:03:52 +00:00
tests Add KeyFilter and deprecate KeyValue object 2022-10-21 20:03:52 +00:00
.gitignore Add Flux from() and filter() methods 2022-08-05 15:41:38 +00:00
composer.json Add KeyFilter and deprecate KeyValue object 2022-10-21 20:03:52 +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 Add KeyFilter and deprecate KeyValue object 2022-10-21 20:03:52 +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.4/query-data/flux/

Installation

composer require arendsen/fluxquerybuilder

Example usage

<?php

use Arendsen\FluxQueryBuilder\QueryBuilder;
use Arendsen\FluxQueryBuilder\Expression\KeyFilter;

$queryBuilder = new QueryBuilder();
$queryBuilder->fromBucket('test_bucket')
    ->addRangeStart(new DateTime('3 hours ago'))
    ->fromMeasurement('test_measurement')
    ->addFieldFilter(['username', 'email'])
    ->addKeyFilter(
        KeyFilter::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