@@ -56,7 +56,7 @@ InfluxDB 2.x client consists of two packages
56
56
57
57
## Supported Platforms
58
58
59
- This package requires Swift 5 and Xcode 12 +.
59
+ This package requires Swift 5.7 and Xcode 14 +.
60
60
61
61
- iOS 14.0+
62
62
- macOS 11.0+
@@ -70,24 +70,24 @@ This package requires Swift 5 and Xcode 12+.
70
70
71
71
Add this line to your ` Package.swift ` :
72
72
73
- ~~~ swift
74
- // swift-tools-version:5.3
73
+ ``` swift
74
+ // swift-tools-version:5.7
75
75
import PackageDescription
76
76
77
77
let package = Package (
78
78
name : " MyPackage" ,
79
79
dependencies : [
80
- .package (name : " influxdb-client-swift" , url : " https://github.com/influxdata/influxdb-client-swift" , from : " 1.7 .0" ),
80
+ .package (name : " influxdb-client-swift" , url : " https://github.com/influxdata/influxdb-client-swift" , from : " 2.0 .0" ),
81
81
],
82
82
targets : [
83
83
.target (name : " MyModule" , dependencies : [
84
- .product (name : " InfluxDBSwift" , package : " influxdb-client-swift" ),
85
- // or InfluxDBSwiftApis for management API
86
- .product (name : " InfluxDBSwiftApis" , package : " influxdb-client-swift" )
84
+ .product (name : " InfluxDBSwift" , package : " influxdb-client-swift" ),
85
+ // or InfluxDBSwiftApis for management API
86
+ .product (name : " InfluxDBSwiftApis" , package : " influxdb-client-swift" )
87
87
])
88
88
]
89
89
)
90
- ~~~
90
+ ```
91
91
92
92
## Usage
93
93
@@ -187,25 +187,27 @@ extension WriteData {
187
187
// Initialize Client with default Bucket and Organization
188
188
//
189
189
let client = InfluxDBClient (
190
- url : url,
191
- token : token,
192
- options : InfluxDBClient.InfluxDBOptions (bucket : bucket, org : org) )
193
-
190
+ url : url,
191
+ token : token,
192
+ options : InfluxDBClient.InfluxDBOptions (bucket : bucket, org : org)
193
+ )
194
194
//
195
195
// Record defined as Data Point
196
196
//
197
- let recordPoint = InfluxDBClient
198
- .Point (" demo" )
199
- .addTag (key : " type" , value : " point" )
200
- .addField (key : " value" , value : .int (2 ))
197
+ let recordPoint = InfluxDBClient.Point (
198
+ " demo" ,
199
+ tags : [" type" : " point" ],
200
+ fields : [" value" : .int (2 )]
201
+ )
201
202
//
202
203
// Record defined as Data Point with Timestamp
203
204
//
204
- let recordPointDate = InfluxDBClient
205
- .Point (" demo" )
206
- .addTag (key : " type" , value : " point-timestamp" )
207
- .addField (key : " value" , value : .int (2 ))
208
- .time (time : .date (Date ()))
205
+ let recordPointDate = InfluxDBClient.Point (
206
+ " demo" ,
207
+ tags : [" type" : " point-timestamp" ],
208
+ fields : [" value" : .int (2 )],
209
+ time : .date (Date ())
210
+ )
209
211
210
212
try await client.makeWriteAPI ().write (points : [recordPoint, recordPointDate])
211
213
print (" Written data:\n\n \( [recordPoint, recordPointDate].map { " \t - \( $0 ) " }.joined (separator : " \n " ) ) " )
@@ -375,10 +377,11 @@ extension ParameterizedQuery {
375
377
options : InfluxDBClient.InfluxDBOptions (bucket : bucket, org : org))
376
378
377
379
for index in 1 ... 3 {
378
- let point = InfluxDBClient
379
- .Point (" demo" )
380
- .addTag (key : " type" , value : " point" )
381
- .addField (key : " value" , value : .int (index))
380
+ let point = InfluxDBClient.Point (
381
+ " demo" ,
382
+ tags : [" type" : " point" ],
383
+ fields : [" value" , value : .int (index)]
384
+ )
382
385
try await client.makeWriteAPI ().write (point : point)
383
386
}
384
387
@@ -602,9 +605,11 @@ let tuple: InfluxDBClient.Point.Tuple
602
605
= (measurement : " mem" , tags : [" tag" : " a" ], fields : [" value" : .int (3 )], time : nil )
603
606
604
607
let records: [Any ] = [
605
- InfluxDBClient.Point (" mining" )
606
- .addTag (key : " sensor_state" , value : " normal" )
607
- .addField (key : " depth" , value : .int (2 )),
608
+ InfluxDBClient.Point (
609
+ " mining" ,
610
+ tags : [" sensor_state" : " normal" ],
611
+ fields : [" depth" : .int (2 )]
612
+ ),
608
613
tuple
609
614
]
610
615
0 commit comments