@@ -29,7 +29,7 @@ public class CollectionManager {
2929 var documentChangeListeners = [ String: Any] ( )
3030
3131 // MARK: - Singleton
32- static let shared = CollectionManager ( )
32+ public static let shared = CollectionManager ( )
3333
3434 // MARK: - Private initializer to prevent external instatiation
3535 private init ( ) {
@@ -105,7 +105,7 @@ public class CollectionManager {
105105 }
106106 }
107107
108- func deleteIndex( _ indexName: String ,
108+ public func deleteIndex( _ indexName: String ,
109109 collectionName: String ,
110110 scopeName: String ,
111111 databaseName: String ) throws {
@@ -126,7 +126,7 @@ public class CollectionManager {
126126 }
127127 }
128128
129- func indexes( _ collectionName: String ,
129+ public func indexes( _ collectionName: String ,
130130 scopeName: String ,
131131 databaseName: String ) throws -> [ String ] {
132132
@@ -142,7 +142,7 @@ public class CollectionManager {
142142
143143 // MARK: Document Functions
144144
145- func documentsCount( _ collectionName: String ,
145+ public func documentsCount( _ collectionName: String ,
146146 scopeName: String ,
147147 databaseName: String ) throws -> UInt64 {
148148
@@ -158,12 +158,12 @@ public class CollectionManager {
158158 return collection. count
159159 }
160160
161- func saveDocument( _ documentId: String ,
161+ public func saveDocument( _ documentId: String ,
162162 document: [ String : Any ] ,
163163 concurrencyControl: ConcurrencyControl ? ,
164164 collectionName: String ,
165165 scopeName: String ,
166- databaseName: String ) throws -> String {
166+ databaseName: String ) throws -> ( String , Bool ? ) {
167167
168168 guard let collection = try self . getCollection (
169169 collectionName,
@@ -186,12 +186,12 @@ public class CollectionManager {
186186 if let concurrencyControlValue = concurrencyControl {
187187 let results = try collection. save ( document: mutableDocument, concurrencyControl: concurrencyControlValue)
188188 if results {
189- return " true "
189+ return ( mutableDocument . id , true )
190190 }
191- return " false "
191+ return ( mutableDocument . id , false )
192192 } else {
193193 try collection. save ( document: mutableDocument)
194- return documentId
194+ return ( documentId, nil )
195195 }
196196 } catch {
197197 throw CollectionError . documentError (
@@ -202,7 +202,7 @@ public class CollectionManager {
202202 }
203203 }
204204
205- func document( _ documentId: String ,
205+ public func document( _ documentId: String ,
206206 collectionName: String ,
207207 scopeName: String ,
208208 databaseName: String ) throws -> Document ? {
@@ -228,7 +228,11 @@ public class CollectionManager {
228228 }
229229 }
230230
231- func getBlobContent( _ key: String , documentId: String , collectionName: String , scopeName: String , databaseName: String ) throws -> [ Int ] ? {
231+ public func getBlobContent( _ key: String ,
232+ documentId: String ,
233+ collectionName: String ,
234+ scopeName: String ,
235+ databaseName: String ) throws -> [ Int ] ? {
232236 guard let collection = try self . getCollection (
233237 collectionName,
234238 scopeName: scopeName,
@@ -259,7 +263,7 @@ public class CollectionManager {
259263 return [ ]
260264 }
261265
262- func deleteDocument( _ documentId: String ,
266+ public func deleteDocument( _ documentId: String ,
263267 collectionName: String ,
264268 scopeName: String ,
265269 databaseName: String ) throws {
@@ -291,8 +295,8 @@ public class CollectionManager {
291295 }
292296 }
293297
294- func deleteDocument( _ documentId: String ,
295- concurrencyControl: ConcurrencyControl ,
298+ public func deleteDocument( _ documentId: String ,
299+ concurrencyControl: ConcurrencyControl ? ,
296300 collectionName: String ,
297301 scopeName: String ,
298302 databaseName: String ) throws -> String {
@@ -314,11 +318,17 @@ public class CollectionManager {
314318 scopeName: scopeName,
315319 databaseName: databaseName)
316320 }
317- let result = try collection. delete ( document: document, concurrencyControl: concurrencyControl)
318- if result {
319- return " true "
321+ if let cc = concurrencyControl {
322+ let result = try collection. delete ( document: document, concurrencyControl: cc)
323+ if result {
324+ return " true "
325+ }
326+ return " false "
327+ } else {
328+ try collection. delete ( document: document)
329+ return " "
320330 }
321- return " false "
331+
322332 } catch {
323333 throw CollectionError . documentError (
324334 message: error. localizedDescription,
@@ -328,7 +338,7 @@ public class CollectionManager {
328338 }
329339 }
330340
331- func purgeDocument( _ documentId: String ,
341+ public func purgeDocument( _ documentId: String ,
332342 collectionName: String ,
333343 scopeName: String ,
334344 databaseName: String ) throws {
@@ -353,7 +363,7 @@ public class CollectionManager {
353363 }
354364 }
355365
356- func setDocumentExpiration( _ documentId: String ,
366+ public func setDocumentExpiration( _ documentId: String ,
357367 expiration: Date ? ,
358368 collectionName: String ,
359369 scopeName: String ,
@@ -382,7 +392,7 @@ public class CollectionManager {
382392
383393 }
384394
385- func getDocumentExpiration( _ documentId: String ,
395+ public func getDocumentExpiration( _ documentId: String ,
386396 collectionName: String ,
387397 scopeName: String ,
388398 databaseName: String ) throws -> Date ? {
0 commit comments