write method

Future<void> write(
  1. dynamic data, {
  2. String? bucket,
  3. String? org,
  4. WritePrecision? precision,
})

Write data (Point, String and collection is supported). bucket specifies the destination bucket for writes []

Implementation

Future<void> write(dynamic data,
    {String? bucket, String? org, WritePrecision? precision}) async {
  precision ??= writeOptions!.precision;
  bucket ??= influxDB.bucket;
  org ??= influxDB.org;

  _checkNotNull('precision', precision);
  _checkNotNull('bucket', bucket);
  _checkNotNull('org', org);

  var payload = _payload(data, precision, bucket!, org!, false);

  if (payload == null) {
    throw ArgumentError('Unable to write, no data');
  }

  await writeLineProtocol(payload as String,
      bucket: bucket, org: org, precision: precision);
}