Re: Upgrading to Couchbase Lite-iOS

159 views
Skip to first unread message

Jens Alfke

unread,
May 13, 2013, 1:33:13 PM5/13/13
to mobile-c...@googlegroups.com

On May 13, 2013, at 6:47 AM, Ajith R <ajith...@gmail.com> wrote:

How can I achieve the following with Couchbase-Lite?

    RESTResource* allDbsResource = [[RESTResource alloc] initWithParent:self.couchServer relativePath:@"_all_dbs"];

    NSMutableSet* allDbs = [[NSMutableSet alloc] initWithArray:[allDbsResource GET].responseBody.fromJSON];


self.couchServer.allDatabases

(which will work in CouchCocoa/TouchDB as well. There’s no need to manually load _all_dbs.)

And Since there is no server involved in CBL, How do you suggest me to upgrade from CouchServer, which is used as a connection manager? 

CBLManager is the equivalent of CouchServer.

—Jens

Ajith R

unread,
May 14, 2013, 1:25:45 AM5/14/13
to mobile-c...@googlegroups.com
Thank you Jens!

Ajith R

unread,
May 28, 2013, 7:03:13 AM5/28/13
to mobile-c...@googlegroups.com
Hello,
     Continuing on same topic of transition to CBL, I've one more question.
  Actually, I'm trying to upgrade an app which uses TouchDB version 0.9 and in this app, It collects deviceID and creates a new configuration database(if needed) on server (something like this "config_deviceID"). Later this configuration database link is returned (URL/config_deviceID). So basically, a database is created on the server for very iPad device.  Here are the codes:

   RESTResource* resource = [[RESTResource alloc] initWithURL:[NSURL URLWithString:URL]];

    

    // prepare data to be posted to the server

    NSMutableDictionary *postData = [[NSMutableDictionary alloc] init];

    [postData setValue:"deviceID" forKey:@"deviceid"];

    [postData setValue:"email" forKey:@"email"];

    

    RESTOperation* op = [resource POSTJSON:postData parameters:nil];

  

    if ([[op start] wait]) {

        NSDictionary* response = op.responseBody.fromJSON;

          }

How can I talk to server with Couchbase-lite ? Please suggest me a solution.


On Monday, 13 May 2013 23:03:13 UTC+5:30, Jens Alfke wrote:

Jens Alfke

unread,
May 28, 2013, 3:28:35 PM5/28/13
to mobile-c...@googlegroups.com

On May 28, 2013, at 4:03 AM, Ajith R <ajith...@gmail.com> wrote:

> How can I talk to server with Couchbase-lite ? Please suggest me a solution.

To talk to a remote CouchDB-compatible server, you’ll need to use CouchCocoa. (Yes, it’s fine to include both Couchbase Lite and CouchCocoa in your app. You’ll just need to use different APIs to talk to your local database vs. remote databases.)

—Jens

Ajith R

unread,
Jun 4, 2013, 9:36:18 AM6/4/13
to mobile-c...@googlegroups.com
Well, I'll use CouchCocoa. But then how do you suggest me to handle replication? I need to establish a persistent replication between Couchbase Lite and Remote CouchDB.

Secondly, Remote CouchDB's view has "design document name and view name"(Eg: designDocName001/viewName, designDocName002/viewName) and Couchbase-Lite has "no design document name". So, after replicating remote database to local, how can I access/write design documents/CBLViews ? 

Jens Alfke

unread,
Jun 4, 2013, 11:45:48 AM6/4/13
to mobile-c...@googlegroups.com
On Jun 4, 2013, at 6:36 AM, Ajith R <ajith...@gmail.com> wrote:

Well, I'll use CouchCocoa. But then how do you suggest me to handle replication? I need to establish a persistent replication between Couchbase Lite and Remote CouchDB.

Couchbase Lite does replication. That’s its most important feature, after all. See the docs.

Secondly, Remote CouchDB's view has "design document name and view name"(Eg: designDocName001/viewName, designDocName002/viewName) and Couchbase-Lite has "no design document name". So, after replicating remote database to local, how can I access/write design documents/CBLViews ? 

In both Couchbase Lite and TouchDB you define views as Objective-C blocks, not as JavaScript functions. This is because iOS doesn’t have a publicly available JavaScript interpreter, and Apple’s guidelines forbid you from executing downloaded code. (It’s also faster.) See the docs.

—Jens

Alex Zavatone

unread,
Jun 4, 2013, 1:24:54 PM6/4/13
to mobile-c...@googlegroups.com, mobile-c...@googlegroups.com
That sounds pretty close to what I'm doing as well. Look forward to sharing lessons learned.

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "Mobile Couchbase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ajith R

unread,
Jun 5, 2013, 1:51:34 AM6/5/13
to mobile-c...@googlegroups.com
Ah! I'm very clear. Please excuse me for silly questions and thanks a lot for your great support, Jens.
Reply all
Reply to author
Forward
0 new messages