Skip to content

Commit 006422f

Browse files
committed
rename other DatabaseCollection generic API to use some: argument label
1 parent a445493 commit 006422f

File tree

5 files changed

+20
-32
lines changed

5 files changed

+20
-32
lines changed

Sources/UnidocDB/DatabaseCollection.swift

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ extension DatabaseCollection
160160
extension DatabaseCollection
161161
{
162162
func insert(
163-
_ elements:some Collection<some BSONDocumentEncodable & Identifiable<ElementID>>,
163+
some elements:some Collection<some BSONDocumentEncodable & Identifiable<ElementID>>,
164164
with session:Mongo.Session) async throws
165165
{
166166
if elements.isEmpty
@@ -181,7 +181,8 @@ extension DatabaseCollection
181181
}
182182
extension DatabaseCollection
183183
{
184-
func insert(_ element:some BSONDocumentEncodable & Identifiable<ElementID>,
184+
func insert(
185+
some element:some BSONDocumentEncodable & Identifiable<ElementID>,
185186
with session:Mongo.Session) async throws
186187
{
187188
let response:Mongo.InsertResponse = try await session.run(
@@ -196,7 +197,8 @@ extension DatabaseCollection
196197

197198
extension DatabaseCollection
198199
{
199-
func upsert(_ elements:some Sequence<some BSONDocumentEncodable & Identifiable<ElementID>>,
200+
func upsert(
201+
some elements:some Sequence<some BSONDocumentEncodable & Identifiable<ElementID>>,
200202
with session:Mongo.Session) async throws -> Mongo.Updates<ElementID>
201203
{
202204
let response:Mongo.UpdateResponse<ElementID> = try await session.run(
@@ -208,7 +210,8 @@ extension DatabaseCollection
208210
}
209211

210212
@discardableResult
211-
func upsert(_ element:some BSONDocumentEncodable & Identifiable<ElementID>,
213+
func upsert(
214+
some element:some BSONDocumentEncodable & Identifiable<ElementID>,
212215
with session:Mongo.Session) async throws -> ElementID?
213216
{
214217
let response:Mongo.UpdateResponse<ElementID> = try await session.run(
@@ -221,22 +224,6 @@ extension DatabaseCollection
221224
}
222225
}
223226

224-
extension DatabaseCollection
225-
{
226-
@available(*, deprecated, renamed: "update(some:with:)")
227-
func update(_ elements:some Sequence<some BSONDocumentEncodable & Identifiable<ElementID>>,
228-
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-
}
240227
extension DatabaseCollection
241228
{
242229
func update(
@@ -254,7 +241,8 @@ extension DatabaseCollection
254241
/// the passed document. Returns true if the document was modified, false if the document
255242
/// was not modified, and nil if the document was not found.
256243
@discardableResult
257-
func update(some element:some BSONDocumentEncodable & Identifiable<ElementID>,
244+
func update(
245+
some element:some BSONDocumentEncodable & Identifiable<ElementID>,
258246
with session:Mongo.Session) async throws -> Bool?
259247
{
260248
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
@@ -140,7 +140,7 @@ extension PackageDatabase.Editions
140140
if placement.new
141141
{
142142
// This can fail if we race with another process.
143-
try await self.insert(edition, with: session)
143+
try await self.insert(some: edition, with: session)
144144
}
145145
else if let sha1:SHA1
146146
{

Sources/UnidocDB/Packages/PackageDatabase.Packages.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ extension PackageDatabase.Packages
111111
if placement.new
112112
{
113113
// This can fail if we race with another process.
114-
try await self.insert(record, with: session)
114+
try await self.insert(some: record, with: session)
115115
// Regenerate the JSON list of all packages.
116-
try await meta.upsert(try await self.scan(with: session), with: session)
116+
try await meta.upsert(some: try await self.scan(with: session), with: session)
117117
}
118118
else if let repo:PackageRepo, repo != placement.repo
119119
{

Sources/UnidocDB/Packages/PackageDatabase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ extension PackageDatabase
111111

112112
let upsert:SnapshotReceipt.Upsert
113113

114-
switch try await self.graphs.upsert(snapshot, with: session)
114+
switch try await self.graphs.upsert(some: snapshot, with: session)
115115
{
116116
case nil: upsert = .update
117117
case _?: upsert = .insert

Sources/UnidocDB/Volumes/UnidocDatabase.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,19 @@ extension UnidocDatabase
153153
{
154154
let (index, trees):(SearchIndex<VolumeIdentifier>, [Volume.TypeTree]) = volume.indexes()
155155

156-
try await self.vertices.insert(volume.vertices, with: session)
157-
try await self.names.insert(volume.names, with: session)
158-
try await self.trees.insert(trees, with: session)
159-
try await self.search.insert(index, with: session)
156+
try await self.vertices.insert(some: volume.vertices, with: session)
157+
try await self.names.insert(some: volume.names, with: session)
158+
try await self.trees.insert(some: trees, with: session)
159+
try await self.search.insert(some: index, with: session)
160160

161161
if volume.names.latest
162162
{
163-
try await self.siteMaps.upsert(volume.siteMap(), with: session)
164-
try await self.groups.insert(volume.groups(latest: true), with: session)
163+
try await self.siteMaps.upsert(some: volume.siteMap(), with: session)
164+
try await self.groups.insert(some: volume.groups(latest: true), with: session)
165165
}
166166
else
167167
{
168-
try await self.groups.insert(volume.groups, with: session)
168+
try await self.groups.insert(some: volume.groups, with: session)
169169
}
170170
if let latest:Unidoc.Zone = volume.latest
171171
{

0 commit comments

Comments
 (0)