Skip to content

Commit

Permalink
Update version to 2.0DB020
Browse files Browse the repository at this point in the history
Updated version to 2.0DB020 and code walkthrough.
  • Loading branch information
pasin committed Nov 17, 2017
1 parent 1de7dfd commit ac1bc88
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 45 deletions.
2 changes: 1 addition & 1 deletion CouchbaseLite.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'CouchbaseLite'
s.version = '2.0DB019'
s.version = '2.0DB020'
s.license = 'Apache License, Version 2.0'
s.homepage = 'http://mobile.couchbase.com'
s.summary = 'An embedded syncable NoSQL database for iOS, tvOS, and MacOS apps.'
Expand Down
2 changes: 1 addition & 1 deletion CouchbaseLiteSwift.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'CouchbaseLiteSwift'
s.version = '2.0DB019'
s.version = '2.0DB020'
s.license = 'Apache License, Version 2.0'
s.homepage = 'http://mobile.couchbase.com'
s.summary = 'An embedded syncable NoSQL database for iOS, tvOS, and MacOS apps.'
Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -23,15 +23,15 @@ You can use [CocoaPods](https://cocoapods.org/) to install `CouchbaseLite` for O
```
target '<your target name>' do
use_frameworks!
pod 'CouchbaseLite', :git => 'https://github.com/couchbase/couchbase-lite-ios.git', :tag => '2.0DB019', :submodules => true
pod 'CouchbaseLite', :git => 'https://github.com/couchbase/couchbase-lite-ios.git', :tag => '2.0DB020', :submodules => true
end
```

#### CouchbaseLiteSwift (Swift API)
```
target '<your target name>' do
use_frameworks!
pod 'CouchbaseLiteSwift', :git => 'https://github.com/couchbase/couchbase-lite-ios.git', :tag => '2.0DB019', :submodules => true
pod 'CouchbaseLiteSwift', :git => 'https://github.com/couchbase/couchbase-lite-ios.git', :tag => '2.0DB020', :submodules => true
end
```

Expand All @@ -40,7 +40,7 @@ end
You can use [Carthage](https://github.com/Carthage/Carthage) to install `CouchbaseLite` by adding it in your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile):

```
github "couchbase/couchbase-lite-ios" "2.0DB019"
github "couchbase/couchbase-lite-ios" "2.0DB020"
```

> When running `carthage update or build`, Carthage will build both CouchbaseLite and CouchbaseLiteSwift framework.
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/objc-api-walkthrough/Cartfile
@@ -1 +1 @@
github "couchbase/couchbase-lite-ios" "version/2.0DB018"
github "couchbase/couchbase-lite-ios" "feature/2.0"
2 changes: 1 addition & 1 deletion docs/examples/objc-api-walkthrough/Cartfile.resolved
@@ -1 +1 @@
github "couchbase/couchbase-lite-ios" "4373a8c8c4a1ae49be157b8491c1bb1b915625aa"
github "couchbase/couchbase-lite-ios" "1de7dfd1fa90de54eadb95df64b75692e9d5e983"
Expand Up @@ -10,11 +10,10 @@

@implementation ExampleConflictResolver

- (nullable CBLReadOnlyDocument*) resolve: (CBLConflict*)conflict {
CBLReadOnlyDocument* base = conflict.base;
CBLReadOnlyDocument* mine = conflict.mine;
CBLReadOnlyDocument* theirs = conflict.theirs;

- (nullable CBLDocument*) resolve: (CBLConflict*)conflict {
CBLDocument* base = conflict.base;
CBLDocument* mine = conflict.mine;
CBLDocument* theirs = conflict.theirs;
return theirs;
}

Expand Down
Expand Up @@ -30,8 +30,7 @@ - (void)viewDidLoad {
}

// create document
// NSError* error;
CBLDocument* newTask = [[CBLDocument alloc] init];
CBLMutableDocument* newTask = [[CBLMutableDocument alloc] init];
[newTask setObject:@"task-list" forKey:@"type"];
[newTask setObject:@"todo" forKey:@"owner"];
[newTask setObject:[NSDate date] forKey:@"createAt"];
Expand All @@ -47,10 +46,9 @@ - (void)viewDidLoad {

// database batch operation
[database inBatch:&error do:^{
for (int i = 1; i <= 10; i++)
{
for (int i = 1; i <= 10; i++) {
NSError* error;
CBLDocument *doc = [[CBLDocument alloc] init];
CBLMutableDocument *doc = [[CBLMutableDocument alloc] init];
[doc setObject:@"user" forKey:@"type"];
[doc setObject:[NSString stringWithFormat:@"user %d", i] forKey:@"name"];
[doc setBoolean:@FALSE forKey:@"admin"];
Expand All @@ -66,7 +64,6 @@ - (void)viewDidLoad {
CBLBlob *blob = [[CBLBlob alloc] initWithContentType:@"image/jpg" data:data];
[newTask setObject:blob forKey: @"avatar"];

// NSError* error;
[database saveDocument: newTask error:&error];
if (error) {
NSLog(@"Cannot save document %@", error);
Expand All @@ -91,7 +88,7 @@ - (void)viewDidLoad {
// insert documents
NSArray *tasks = @[@"buy groceries", @"play chess", @"book travels", @"buy museum tickets"];
for (NSString* task in tasks) {
CBLDocument* doc = [[CBLDocument alloc] init];
CBLMutableDocument* doc = [[CBLMutableDocument alloc] init];
[doc setObject: @"task" forKey: @"type"];
[doc setObject: task forKey: @"name"];

Expand All @@ -115,9 +112,9 @@ - (void)viewDidLoad {
from:[CBLQueryDataSource database:database]
where:where];

NSEnumerator* ftsQueryResult = [ftsQuery run:&error];
for (CBLFullTextQueryRow *row in ftsQueryResult) {
NSLog(@"document properties :: %@", [row.document toDictionary]);
NSEnumerator* results = [ftsQuery run:&error];
for (CBLQueryResult *row in results) {
NSLog(@"document properties :: %@", [row toDictionary]);
}

// create conflict
Expand All @@ -127,9 +124,9 @@ - (void)viewDidLoad {
* `mine` is what's being saved.
* 3. Read the document after the second save operation and verify its property is as expected.
*/
CBLDocument* theirs = [[CBLDocument alloc] initWithID:@"buzz"];
CBLMutableDocument* theirs = [[CBLMutableDocument alloc] initWithID:@"buzz"];
[theirs setObject:@"theirs" forKey:@"status"];
CBLDocument* mine = [[CBLDocument alloc] initWithID:@"buzz"];
CBLMutableDocument* mine = [[CBLMutableDocument alloc] initWithID:@"buzz"];
[mine setObject:@"mine" forKey:@"status"];
[database saveDocument:theirs error:nil];
[database saveDocument:mine error:nil];
Expand All @@ -151,11 +148,4 @@ - (void)viewDidLoad {
}];
}


- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}


@end
2 changes: 1 addition & 1 deletion docs/examples/swift-api-walkthrough/Cartfile
@@ -1 +1 @@
github "couchbase/couchbase-lite-ios" "version/2.0DB018"
github "couchbase/couchbase-lite-ios" "feature/2.0"
2 changes: 1 addition & 1 deletion docs/examples/swift-api-walkthrough/Cartfile.resolved
@@ -1 +1 @@
github "couchbase/couchbase-lite-ios" "4373a8c8c4a1ae49be157b8491c1bb1b915625aa"
github "couchbase/couchbase-lite-ios" "1de7dfd1fa90de54eadb95df64b75692e9d5e983"
Expand Up @@ -10,11 +10,10 @@ import Foundation
import CouchbaseLiteSwift

class ExampleConflictResolver: ConflictResolver {
func resolve(conflict: Conflict) -> ReadOnlyDocument? {
func resolve(conflict: Conflict) -> Document? {
let base = conflict.base
let mine = conflict.mine
let theirs = conflict.theirs

return theirs
}
}
Expand Up @@ -30,7 +30,7 @@ class ViewController: UIViewController {
let dict: [String: Any] = ["type": "task",
"owner": "todo",
"createdAt": Date()]
let newTask = Document(dictionary: dict)
let newTask = MutableDocument(dictionary: dict)
try? database.save(newTask)

// mutate document
Expand All @@ -45,12 +45,12 @@ class ViewController: UIViewController {
do {
try database.inBatch {
for i in 0...10 {
let doc = Document()
let doc = MutableDocument()
doc.setValue("user", forKey: "type")
doc.setValue("user \(i)", forKey: "name")
doc.setBoolean(false, forKey: "admin")
try database.save(doc)
print("saved user document \(doc.string(forKey: "name"))")
print("saved user document \(doc.string(forKey: "name")!)")
}
}
} catch let error {
Expand All @@ -66,7 +66,7 @@ class ViewController: UIViewController {
try? database.save(newTask)

if let taskBlob = newTask.blob(forKey: "image") {
UIImage(data: taskBlob.content!)
let image = UIImage(data: taskBlob.content!)
}

// query
Expand All @@ -91,7 +91,7 @@ class ViewController: UIViewController {
// Insert documents
let tasks = ["buy groceries", "play chess", "book travels", "buy museum tickets"]
for task in tasks {
let doc = Document()
let doc = MutableDocument()
doc.setString("task", forKey: "type")
doc.setString(task, forKey: "name")
try? database.save(doc)
Expand All @@ -114,7 +114,7 @@ class ViewController: UIViewController {
do {
let ftsQueryResult = try ftsQuery.run()
for row in ftsQueryResult {
print("document properties \(row.string(forKey: "_id"))")
print("document properties \(row.string(forKey: "_id")!)")
}
} catch let error {
print(error.localizedDescription)
Expand All @@ -127,9 +127,9 @@ class ViewController: UIViewController {
* `mine` is what's being saved.
* 3. Read the document after the second save operation and verify its property is as expected.
*/
let theirs = Document("buzz")
let theirs = MutableDocument("buzz")
theirs.setString("theirs", forKey: "status")
let mine = Document("buzz")
let mine = MutableDocument("buzz")
mine.setString("mine", forKey: "status")
do {
try database.save(theirs)
Expand All @@ -139,7 +139,7 @@ class ViewController: UIViewController {
}

let conflictResolverResult = database.getDocument("buzz")
print("conflictResolverResult doc.status ::: \(conflictResolverResult?.string(forKey: "status"))")
print("conflictResolverResult doc.status ::: \(conflictResolverResult!.string(forKey: "status")!)")

// replication
/**
Expand Down Expand Up @@ -181,7 +181,7 @@ class ViewController: UIViewController {
return
}

let document = Document()
let document = MutableDocument()
document.setString("created on background thread", forKey: "status")
try? database.save(document)
}
Expand Down

0 comments on commit ac1bc88

Please sign in to comment.