|
| 1 | +# RecordRow |
| 2 | + |
| 3 | +Using 'FluxRecord.row' in case of duplicated column names in response. |
| 4 | + |
| 5 | +## Prerequisites: |
| 6 | +- Docker |
| 7 | +- Cloned examples: |
| 8 | + ```bash |
| 9 | + git clone [email protected]:influxdata/influxdb-client-swift.git |
| 10 | + cd Examples/RecordRow |
| 11 | + ``` |
| 12 | + |
| 13 | +## Sources: |
| 14 | +- [Package.swift](/Examples/RecordRow/Package.swift) |
| 15 | +- [RecordRow.swift](/Examples/RecordRow/Sources/RecordRow/RecordRow.swift) |
| 16 | + |
| 17 | +## How to test: |
| 18 | +1. Start InfluxDB: |
| 19 | + ```bash |
| 20 | + docker run --rm \ |
| 21 | + --name influxdb_v2 \ |
| 22 | + --detach \ |
| 23 | + --publish 8086:8086 \ |
| 24 | + influxdb:latest |
| 25 | + ``` |
| 26 | +2. Configure your username, password, organization, bucket and token: |
| 27 | + ```bash |
| 28 | + docker run --rm \ |
| 29 | + --link influxdb_v2 \ |
| 30 | + curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \ |
| 31 | + -H 'accept: application/json' \ |
| 32 | + -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}' |
| 33 | + ``` |
| 34 | +3. Start SwiftCLI by: |
| 35 | + ```bash |
| 36 | + docker run --rm \ |
| 37 | + --link influxdb_v2 \ |
| 38 | + --privileged \ |
| 39 | + --interactive \ |
| 40 | + --tty \ |
| 41 | + --volume $PWD/../..:/client \ |
| 42 | + --workdir /client/Examples/RecordRow \ |
| 43 | + swift:5.7 /bin/bash |
| 44 | + ``` |
| 45 | +4. Execute by: |
| 46 | + ```bash |
| 47 | + swift run record-row --org my-org --bucket my-bucket --token my-token --url http://influxdb_v2:8086 |
| 48 | + ``` |
| 49 | + |
| 50 | +## Expected output |
| 51 | + |
| 52 | +```bash |
| 53 | +The response contains columns with duplicated names: result, table |
| 54 | +You should use the 'FluxRecord.row' to access your data instead of 'FluxRecord.values' dictionary. |
| 55 | +------------------------------------------ FluxRecord.values ------------------------------------------ |
| 56 | +_measurement: point, _start: 2022-10-13 07:56:08 +0000, _stop: 2022-10-13 07:57:08 +0000, _time: 2022-10-13 07:57:08 +0000, result: 1.0, table: my-table |
| 57 | +_measurement: point, _start: 2022-10-13 07:56:08 +0000, _stop: 2022-10-13 07:57:08 +0000, _time: 2022-10-13 07:57:08 +0000, result: 2.0, table: my-table |
| 58 | +_measurement: point, _start: 2022-10-13 07:56:08 +0000, _stop: 2022-10-13 07:57:08 +0000, _time: 2022-10-13 07:57:08 +0000, result: 3.0, table: my-table |
| 59 | +_measurement: point, _start: 2022-10-13 07:56:08 +0000, _stop: 2022-10-13 07:57:08 +0000, _time: 2022-10-13 07:57:08 +0000, result: 4.0, table: my-table |
| 60 | +_measurement: point, _start: 2022-10-13 07:56:08 +0000, _stop: 2022-10-13 07:57:08 +0000, _time: 2022-10-13 07:57:08 +0000, result: 5.0, table: my-table |
| 61 | +-------------------------------------------- FluxRecord.row ------------------------------------------- |
| 62 | +_result, 0, 2022-10-13 07:56:08 +0000, 2022-10-13 07:57:08 +0000, 2022-10-13 07:57:08 +0000, point, 1.0, my-table |
| 63 | +_result, 0, 2022-10-13 07:56:08 +0000, 2022-10-13 07:57:08 +0000, 2022-10-13 07:57:08 +0000, point, 2.0, my-table |
| 64 | +_result, 0, 2022-10-13 07:56:08 +0000, 2022-10-13 07:57:08 +0000, 2022-10-13 07:57:08 +0000, point, 3.0, my-table |
| 65 | +_result, 0, 2022-10-13 07:56:08 +0000, 2022-10-13 07:57:08 +0000, 2022-10-13 07:57:08 +0000, point, 4.0, my-table |
| 66 | +_result, 0, 2022-10-13 07:56:08 +0000, 2022-10-13 07:57:08 +0000, 2022-10-13 07:57:08 +0000, point, 5.0, my-table |
| 67 | +
|
| 68 | +``` |
0 commit comments