Skip to content

Commit b5d2ba8

Browse files
feature: Adds hisWrite
1 parent 5080e5e commit b5d2ba8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Sources/HaystackClient/HaystackClient.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ public class HaystackClient {
170170
return try await post(path: "hisRead", args: ["id": id, "range": range.toRequestString()])
171171
}
172172

173+
public func hisWrite(id: Ref, items: [HisItem]) async throws -> Grid {
174+
let builder = GridBuilder()
175+
builder.setMeta(["id": id])
176+
try builder.addCol(name: "ts")
177+
try builder.addCol(name: "val")
178+
for item in items {
179+
try builder.addRow([item.ts, item.val])
180+
}
181+
return try await post(path: "hisWrite", grid: builder.toGrid())
182+
}
183+
173184

174185
public func watchSubCreate(
175186
watchDis: String,
@@ -420,3 +431,13 @@ public enum HisReadRange {
420431
}
421432
}
422433
}
434+
435+
public struct HisItem {
436+
let ts: DateTime
437+
let val: any Val
438+
439+
public init(ts: DateTime, val: any Val) {
440+
self.ts = ts
441+
self.val = val
442+
}
443+
}

0 commit comments

Comments
 (0)