Skip to content

Commit 8f31afc

Browse files
committed
initial check-in
1 parent 7a08c6c commit 8f31afc

File tree

17 files changed

+348
-1448
lines changed

17 files changed

+348
-1448
lines changed

CbliteSwiftJsLib.podspec

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,5 @@ Pod::Spec.new do |s|
3131
s.swift_version = '5.5'
3232

3333
s.source_files = 'CbliteSwiftJsLib/Classes/**/*'
34-
35-
# s.public_header_files = 'Pod/Classes/**/*.h'
36-
3734
s.dependency 'CouchbaseLite-Swift-Enterprise', '~> 3.1'
38-
s.dependency 'CouchbaseLite-Enterprise', '~> 3.1'
3935
end

CbliteSwiftJsLib/Classes/CollectionManager.swift

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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? {

CbliteSwiftJsLib/Classes/CustomQuery.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

CbliteSwiftJsLib/Classes/CustomQuery.m

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)