Skip to content

Commit a445493

Browse files
committed
rename generic update methods to use label
1 parent 08b846c commit a445493

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
strategy:
1515
matrix:
1616
image:
17-
- swift:5.9-amazonlinux2
18-
- swift:5.9-jammy
17+
- swift:5.9.0-amazonlinux2
18+
- swift:5.9.0-jammy
1919
steps:
2020
- name: checkout repository
2121
uses: actions/checkout@v3

Sources/UnidocDB/DatabaseCollection.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ extension DatabaseCollection
119119
{
120120
for try await batch:[Master] in $0
121121
{
122-
let updates:Mongo.Updates<ElementID> = try await self.update(batch,
122+
let updates:Mongo.Updates<ElementID> = try await self.update(some: batch,
123123
with: session)
124124

125125
modified += updates.modified
@@ -223,8 +223,25 @@ extension DatabaseCollection
223223

224224
extension DatabaseCollection
225225
{
226+
@available(*, deprecated, renamed: "update(some:with:)")
226227
func update(_ elements:some Sequence<some BSONDocumentEncodable & Identifiable<ElementID>>,
227228
with session:Mongo.Session) async throws -> Mongo.Updates<ElementID>
229+
{
230+
try await self.update(some: elements, with: session)
231+
}
232+
@available(*, deprecated, renamed: "update(some:with:)")
233+
@discardableResult
234+
func update(_ element:some BSONDocumentEncodable & Identifiable<ElementID>,
235+
with session:Mongo.Session) async throws -> Bool?
236+
{
237+
try await self.update(some: element, with: session)
238+
}
239+
}
240+
extension DatabaseCollection
241+
{
242+
func update(
243+
some elements:some Sequence<some BSONDocumentEncodable & Identifiable<ElementID>>,
244+
with session:Mongo.Session) async throws -> Mongo.Updates<ElementID>
228245
{
229246
let response:Mongo.UpdateResponse<ElementID> = try await session.run(
230247
command: Mongo.Update<Mongo.One, ElementID>.init(Self.name,
@@ -237,7 +254,7 @@ extension DatabaseCollection
237254
/// the passed document. Returns true if the document was modified, false if the document
238255
/// was not modified, and nil if the document was not found.
239256
@discardableResult
240-
func update(_ element:some BSONDocumentEncodable & Identifiable<ElementID>,
257+
func update(some element:some BSONDocumentEncodable & Identifiable<ElementID>,
241258
with session:Mongo.Session) async throws -> Bool?
242259
{
243260
let response:Mongo.UpdateResponse<ElementID> = try await session.run(

Sources/UnidocDB/Packages/PackageDatabase.Editions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ extension PackageDatabase.Editions
153153
// arbitrary choice of hash without marking the edition dirty.
154154
// We should use `placement.sha1` as a hint to skip the update only,
155155
// and set the dirty flag within a custom update statement.
156-
try await self.update(edition, with: session)
156+
try await self.update(some: edition, with: session)
157157

158158
case sha1?:
159159
// Nothing to do.

Sources/UnidocDB/Packages/PackageDatabase.Packages.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extension PackageDatabase.Packages
8686
func update(record:PackageRecord,
8787
with session:Mongo.Session) async throws -> Bool?
8888
{
89-
try await self.update(record, with: session)
89+
try await self.update(some: record, with: session)
9090
}
9191
}
9292
extension PackageDatabase.Packages
@@ -117,7 +117,7 @@ extension PackageDatabase.Packages
117117
}
118118
else if let repo:PackageRepo, repo != placement.repo
119119
{
120-
try await self.update(record, with: session)
120+
try await self.update(some: record, with: session)
121121
placement.repo = repo
122122
}
123123

0 commit comments

Comments
 (0)