File tree 2 files changed +18
-16
lines changed
2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -53,15 +53,16 @@ final class BookmarkRepository {
53
53
}
54
54
}
55
55
56
- func add( _ bookmark: Bookmark ) -> AnyPublisher < Bookmark . Id , Error > {
57
- return db. writePublisher { db in
56
+ @discardableResult
57
+ func add( _ bookmark: Bookmark ) async throws -> Bookmark . Id {
58
+ try await db. write { db in
58
59
try bookmark. insert ( db)
59
60
return Bookmark . Id ( rawValue: db. lastInsertedRowID)
60
- } . eraseToAnyPublisher ( )
61
+ }
61
62
}
62
-
63
- func remove( _ id: Bookmark . Id ) -> AnyPublisher < Void , Error > {
64
- db. writePublisher { db in try Bookmark . deleteOne ( db, key: id) }
63
+
64
+ func remove( _ id: Bookmark . Id ) async throws {
65
+ try await db. write { db in try Bookmark . deleteOne ( db, key: id) }
65
66
}
66
67
67
68
}
Original file line number Diff line number Diff line change @@ -91,23 +91,24 @@ final class HighlightRepository {
91
91
}
92
92
}
93
93
94
- func add( _ highlight: Highlight ) -> AnyPublisher < Highlight . Id , Error > {
95
- return db. writePublisher { db in
94
+ @discardableResult
95
+ func add( _ highlight: Highlight ) async throws -> Highlight . Id {
96
+ try await db. write { db in
96
97
try highlight. insert ( db)
97
98
return highlight. id
98
- } . eraseToAnyPublisher ( )
99
+ }
99
100
}
100
-
101
- func update( _ id: Highlight . Id , color: HighlightColor ) -> AnyPublisher < Void , Error > {
102
- return db. writePublisher { db in
101
+
102
+ func update( _ id: Highlight . Id , color: HighlightColor ) async throws {
103
+ try await db. write { db in
103
104
let filtered = Highlight . filter ( Highlight . Columns. id == id)
104
105
let assignment = Highlight . Columns. color. set ( to: color)
105
106
try filtered. updateAll ( db, onConflict: nil , assignment)
106
- } . eraseToAnyPublisher ( )
107
+ }
107
108
}
108
-
109
- func remove( _ id: Highlight . Id ) -> AnyPublisher < Void , Error > {
110
- db. writePublisher { db in try Highlight . deleteOne ( db, key: id) }
109
+
110
+ func remove( _ id: Highlight . Id ) async throws {
111
+ try await db. write { db in try Highlight . deleteOne ( db, key: id) }
111
112
}
112
113
113
114
}
You can’t perform that action at this time.
0 commit comments