Skip to content

Commit b8dd97d

Browse files
committed
SWIFT-680 Enable and run swiftformat on sync API
1 parent aa78672 commit b8dd97d

File tree

7 files changed

+66
-50
lines changed

7 files changed

+66
-50
lines changed

.swiftformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
--exclude Sources/MongoSwift/MongoSwiftVersion.swift,Sources/MongoSwiftSync/*
1+
--exclude Sources/MongoSwift/MongoSwiftVersion.swift,Sources/MongoSwiftSync/Exports.swift
22
--exclude .build/*
33

44
# unnecessary

Sources/MongoSwiftSync/MongoClient.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ public class MongoClient {
190190
session: ClientSession? = nil
191191
) throws -> ChangeStream<ChangeStreamEvent<Document>> {
192192
return try self.watch(
193-
pipeline,
194-
options: options,
195-
session: session,
196-
withEventType: ChangeStreamEvent<Document>.self
193+
pipeline,
194+
options: options,
195+
session: session,
196+
withEventType: ChangeStreamEvent<Document>.self
197197
)
198198
}
199199

@@ -232,10 +232,10 @@ public class MongoClient {
232232
withFullDocumentType _: FullDocType.Type
233233
) throws -> ChangeStream<ChangeStreamEvent<FullDocType>> {
234234
return try self.watch(
235-
pipeline,
236-
options: options,
237-
session: session,
238-
withEventType: ChangeStreamEvent<FullDocType>.self
235+
pipeline,
236+
options: options,
237+
session: session,
238+
withEventType: ChangeStreamEvent<FullDocType>.self
239239
)
240240
}
241241

Sources/MongoSwiftSync/MongoCollection+FindAndModify.swift

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ extension MongoCollection {
5555
options: FindOneAndReplaceOptions? = nil,
5656
session: ClientSession? = nil
5757
) throws -> CollectionType? {
58-
return try self.asyncColl.findOneAndReplace(filter: filter,
59-
replacement: replacement,
60-
options: options,
61-
session: session?.asyncSession)
62-
.wait()
58+
return try self.asyncColl.findOneAndReplace(
59+
filter: filter,
60+
replacement: replacement,
61+
options: options,
62+
session: session?.asyncSession
63+
)
64+
.wait()
6365
}
6466

6567
/**
@@ -88,10 +90,12 @@ extension MongoCollection {
8890
options: FindOneAndUpdateOptions? = nil,
8991
session: ClientSession? = nil
9092
) throws -> CollectionType? {
91-
return try self.asyncColl.findOneAndUpdate(filter: filter,
92-
update: update,
93-
options: options,
94-
session: session?.asyncSession)
95-
.wait()
93+
return try self.asyncColl.findOneAndUpdate(
94+
filter: filter,
95+
update: update,
96+
options: options,
97+
session: session?.asyncSession
98+
)
99+
.wait()
96100
}
97101
}

Sources/MongoSwiftSync/MongoCollection+Indexes.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ extension MongoCollection {
2727
options: CreateIndexOptions? = nil,
2828
session: ClientSession? = nil
2929
) throws -> String {
30-
return try self.asyncColl.createIndex(keys,
31-
indexOptions: indexOptions,
32-
options: options,
33-
session: session?.asyncSession)
34-
.wait()
30+
return try self.asyncColl.createIndex(
31+
keys,
32+
indexOptions: indexOptions,
33+
options: options,
34+
session: session?.asyncSession
35+
)
36+
.wait()
3537
}
3638

3739
/**

Sources/MongoSwiftSync/MongoCollection+Read.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ extension MongoCollection {
6969
session: ClientSession? = nil
7070
) throws -> MongoCursor<Document> {
7171
let asyncCursor = try self.asyncColl.aggregate(pipeline, options: options, session: session?.asyncSession)
72-
.wait()
72+
.wait()
7373
return MongoCursor(wrapping: asyncCursor, client: self.client)
7474
}
7575

@@ -132,10 +132,12 @@ extension MongoCollection {
132132
options: DistinctOptions? = nil,
133133
session: ClientSession? = nil
134134
) throws -> [BSON] {
135-
return try self.asyncColl.distinct(fieldName: fieldName,
136-
filter: filter,
137-
options: options,
138-
session: session?.asyncSession)
139-
.wait()
135+
return try self.asyncColl.distinct(
136+
fieldName: fieldName,
137+
filter: filter,
138+
options: options,
139+
session: session?.asyncSession
140+
)
141+
.wait()
140142
}
141143
}

Sources/MongoSwiftSync/MongoCollection+Write.swift

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ extension MongoCollection {
8383
options: ReplaceOptions? = nil,
8484
session: ClientSession? = nil
8585
) throws -> UpdateResult? {
86-
return try self.asyncColl.replaceOne(filter: filter,
87-
replacement: replacement,
88-
options: options,
89-
session: session?.asyncSession)
90-
.wait()
86+
return try self.asyncColl.replaceOne(
87+
filter: filter,
88+
replacement: replacement,
89+
options: options,
90+
session: session?.asyncSession
91+
)
92+
.wait()
9193
}
9294

9395
/**
@@ -116,11 +118,13 @@ extension MongoCollection {
116118
options: UpdateOptions? = nil,
117119
session: ClientSession? = nil
118120
) throws -> UpdateResult? {
119-
return try self.asyncColl.updateOne(filter: filter,
120-
update: update,
121-
options: options,
122-
session: session?.asyncSession)
123-
.wait()
121+
return try self.asyncColl.updateOne(
122+
filter: filter,
123+
update: update,
124+
options: options,
125+
session: session?.asyncSession
126+
)
127+
.wait()
124128
}
125129

126130
/**
@@ -149,11 +153,13 @@ extension MongoCollection {
149153
options: UpdateOptions? = nil,
150154
session: ClientSession? = nil
151155
) throws -> UpdateResult? {
152-
return try self.asyncColl.updateMany(filter: filter,
153-
update: update,
154-
options: options,
155-
session: session?.asyncSession)
156-
.wait()
156+
return try self.asyncColl.updateMany(
157+
filter: filter,
158+
update: update,
159+
options: options,
160+
session: session?.asyncSession
161+
)
162+
.wait()
157163
}
158164

159165
/**

Sources/MongoSwiftSync/MongoDatabase.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,13 @@ public struct MongoDatabase {
135135
options: CreateCollectionOptions? = nil,
136136
session: ClientSession? = nil
137137
) throws -> MongoCollection<T> {
138-
let asyncColl = try self.asyncDB.createCollection(name,
139-
withType: type,
140-
options: options,
141-
session: session?.asyncSession)
142-
.wait()
138+
let asyncColl = try self.asyncDB.createCollection(
139+
name,
140+
withType: type,
141+
options: options,
142+
session: session?.asyncSession
143+
)
144+
.wait()
143145
return MongoCollection(client: self.client, asyncCollection: asyncColl)
144146
}
145147

0 commit comments

Comments
 (0)