How to use Couchbase lite in iOS? and Don't want to synch online and offline mode

#1

Hi Guys, CouchBase is awesome, i have been using for one of my app for online and offline mode. i have doubt regarding CouchBasebase Lite Mobile.

I want to build an App in iOS and i want to choose Couchbase Server as my backend. I know by using Couchbase Lite Mobile SDK we can do it. But this SDK synch documents in iPhone localdirectory. I dont want to synch app in online and offline mode, i need online mode always.

so what should i do, can i use Rest API for accessing documents in Couchbase Server? or else is it possible to do it by using CouchBasebase Lite Mobile SDK?

#2

Couchbase Lite cannot communicate directly with Couchbase Server and even if it could disabling the local storage defeats the goal of the library. For iOS your best bet would probably be the libcouchbase C client API found here

#3

You should go with a more typical approach where you build an app server that talks to Couchbase Server using one of our SDKs, and exposes a REST API for your app to talk to.

Exposing Couchbase Server directly to your app is not a good idea for security reasons – Couchbase should not be reachable directly from the public internet because it doesn’t support the necessary authentication/authorization mechanisms.

#4

@jens, Thanks for reply, can you please elaborate best approach for my requirement. without online and offline synch can i use Couchbase Lite iOS SDK. or else, can i do all tasks like document creation, edit, update and delete by using REST Public API.

#5

No, you cannot use Couchbase Lite without syncing documents to a local database.

#6

Yes, you absolutely can use SG’s REST API for connect, online-only apps. We have quite a few blog posts on how to do this with JavaScript frameworks, and use could easily adapt them to other languages.

#7

@zgramana thanks, please provide the blogs link here. i will look it.

#8

Ok @Jens. but i want to give a feedback to them. where can i keep my feedback to Couchbase support team.

#9

I’m the architect of Couchbase Lite and one of the lead engineers. You can give feedback here.

#10

@jens Sounds Good. what we expecting is, As mobile developer we don’t want to depend on other developers like backend or DB developers. we want to create documents our self and handle our self, we have been doing like that. but Couchbase allowing me to synch offline and online. but we need online only by using SDK. Some times we need to synch specific documents sometimes. So if possible develop like that Couchbase SDKs.

#11

If all you need to do is store and retrieve documents online, you can easily do that by sending HTTP requests to the Sync Gateway’s REST API. You don’t need a specific SDK to do that, just use your platform’s existing HTTP APIs (e.g. NSURLSession on iOS.)

Our mobile documentation portal includes docs on the Sync Gateway’s REST API; those should be enough to get you going.

#12

Thanks @jens can you please share me the link Sync Gateway’s REST API.

#13

http://developer.couchbase.com/documentation/mobile/1.1.0/develop/references/sync-gateway/rest-api/index.html

http://developer.couchbase.com/documentation/mobile/1.1.0/develop/references/sync-gateway/admin-rest-api/index.html

#14

@itssrinadh I’m the product manager for Couchbase Mobile. We are currently in the early stages of building client SDK’s use directly against the Gateway. The expectation is that you would use either Couchbase Lite or the Gateway client library, but not both.

If all you want to do is pull just one or more specific set of docs, you’ll be pleased to know that we’re adding an enhancement in our imminent 1.2 release that enables just that. You can set puller.docIds to an array of document id’s, and Sync Gateway itself will ensure that you receive the latest changes for only those docs. This lets you accomplish exactly the use case you have in mind.

#15

@zgramana Thanks for imminent 1.2 release. One more query how to request a particular docs last 30days data on replication. i have a requirement to get all docs data. but certain docs would be come only for last 30 days data. is it possible with existing SDK?

#16

@itssrinadh,
You can request the particular documents by setting up the query start and end key ranges for a 30 day window and then run the query.

CBLQuery* query = [ordersByDateView createQuery];
query.startKey = @“2016-01-01”;
query.endKey = @“2016-02-01”;

There are other query properties too that you can set that might be relevant like descending and can refer to the Query documentations for additional insights.

#17

@sweetiewill Thank you.

#18

Hello there, actually we have a native android application with sqlite storage. The app works online and offline. We have exposed rest apis and the services run at a scheduled interval.

We were planning to go with phonegap/cordova option since we need to deploy on multiple devices as the next generation of the app. We were going to explore couchbase server and couchbaselite to see if we can get rid of those rest apis, since we would need some plugins to kick off to sync.

So do you recommend not using couchbase server and couchbase lite sync? Do you think we need to use restApis to consume and store the json or data in couchbaselite?

Thank you very much for the reply,
Preethi

#19

@preethi.minti Your app works online and offline. So my strong reference is use Couchbase Base Lite for Mobile Applicaitons because it has a power full tool Couchbase Sync Gateway

Couchbase base offers us to convert our existing db to coubase here are some of the useful links

http://blog.couchbase.com/2016/february/moving-from-oracle-to-couchbase

http://blog.couchbase.com/2016/february/moving-from-mongodb-to-couchbase-server

CouchbaseLite and Couchbase