Skip to content

Commit 11e7d94

Browse files
committed
Add DeleteService (#66)
1 parent d01c7c7 commit 11e7d94

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

README.md

+63
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,69 @@ public class FluxExample {
361361
}
362362
```
363363

364+
### Delete data from InfluxDB 2.0
365+
366+
The following example demonstrates how to delete data from InfluxDB 2.0.
367+
368+
#### Installation
369+
370+
Download the latest version:
371+
372+
##### Maven dependency:
373+
374+
```XML
375+
<dependency>
376+
<groupId>com.influxdb</groupId>
377+
<artifactId>influxdb-client-flux</artifactId>
378+
<version>1.2.0</version>
379+
</dependency>
380+
```
381+
382+
##### Or when using Gradle:
383+
384+
```groovy
385+
dependencies {
386+
compile "com.influxdb:influxdb-client-flux:1.2.0"
387+
}
388+
```
389+
390+
```java
391+
package example;
392+
393+
import java.time.OffsetDateTime;
394+
import java.time.temporal.ChronoUnit;
395+
396+
import com.influxdb.client.DeleteApi;
397+
import com.influxdb.client.InfluxDBClient;
398+
import com.influxdb.client.InfluxDBClientFactory;
399+
import com.influxdb.exceptions.InfluxException;
400+
401+
public class DeleteData {
402+
403+
private static char[] token = "my-token".toCharArray();
404+
405+
public static void main(final String[] args) {
406+
407+
InfluxDBClient influxDBClient = InfluxDBClientFactory.create("http://localhost:9999", token);
408+
409+
DeleteApi deleteApi = influxDBClient.getDeleteApi();
410+
411+
try {
412+
413+
OffsetDateTime start = OffsetDateTime.now().minus(1, ChronoUnit.HOURS);
414+
OffsetDateTime stop = OffsetDateTime.now();
415+
416+
deleteApi.delete(start, stop, "", "my-bucket", "my-org");
417+
418+
} catch (InfluxException ie) {
419+
System.out.println("InfluxException: " + ie);
420+
}
421+
422+
influxDBClient.close();
423+
}
424+
}
425+
```
426+
364427
## Build Requirements
365428

366429
* Java 1.8+ (tested with jdk8)

0 commit comments

Comments
 (0)