Skip to content

Instantly share code, notes, and snippets.

@lucianboboc
Created December 27, 2016 17:17
Show Gist options
  • Select an option

  • Save lucianboboc/24a95fbc7234dbada8b80b1df23ffe2a to your computer and use it in GitHub Desktop.

Select an option

Save lucianboboc/24a95fbc7234dbada8b80b1df23ffe2a to your computer and use it in GitHub Desktop.

Revisions

  1. lucianboboc created this gist Dec 27, 2016.
    33 changes: 33 additions & 0 deletions couchDB update issue
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    let connectionProperties = ConnectionProperties(host: "localhost", port: 5984, secured: false)
    let client = CouchDBClient(connectionProperties: connectionProperties)
    let database = client.database("test")

    func test() {
    let dict = ["key":"value"]
    let json = JSON(dict)
    database.create(json) { id, revision, doc, error in
    if let id = id {
    database.retrieve(id) { doc, error in
    if let doc = doc {
    let id = doc["_id"].stringValue
    let rev = doc["_rev"].stringValue
    var newDocument = doc
    newDocument["key"] = "updated value"

    database.update(id, rev: rev, document: newDocument) { rev, doc, error in
    print("update callback")
    if let rev = rev {
    print(rev)
    } else {
    print(error!)
    }
    }
    }
    }
    }
    }
    }

    test()

    // update callback is never called after the database.update call...