Pull Sync in CouchbaseLite


#1

Do you have a sample Cordova application where the pull replication works? I am only able to push data to the couchbase server but I am not able to pull the data from couchbase to couchbaselite via sync gateway.
I want to really understand what configuration is missing. Any help greatly appreciated.

Preethi


#2

FYI


#3

Thank you! I am able to set this up and get it working. I need to add and edit document on couchbase server and pull them to couchbase light via sync gateway. If I add or edit a document manually in the couchbase server, I am not able to sync them over to couchbase lite. What do I need to do to get this working. Thanks for the help!!


#4

You shouldn’t edit document in the couchbase server directly, you should modify document by sync Gateway REST API


#5

Thank you, I was able to use REST Apis for all CRUD operations. Is there a way to view the couchbaselite database embedded in the mobile app? We currently use sqlite and we can see the database using a sqlite browser. How can we do the same with Couchbaselite just to see the records that are present in that.


#6

Also, I have another question, does the sync gateway just pass the data over to the couchbase or does it actually keep the copy of the data on the server? The reason I ask is, since this will be on the DMZ and public facing, we do not want it to store the data/documents there. As long as the data is just routed to the Couchbase server and not stored there, there is no violation of sensitive data. Could you please let me know about this?


#7

You can use this tools to view data in cbl.
also, you can browser all data using cbl rest api:all_docs.


#8

There is a Couchbase Lite Viewer app.

does the sync gateway just pass the data over to the couchbase or does it actually keep the copy of the data on the server?

The data lives in a bucket in the Couchbase Server. The Sync Gateway just routes data between that bucket and the Couchbase Lite clients; it has no persistent storage of its own.


#9

@jens Can Couchbase Lite Viewer support CouchbaseLite 1.2.0 ,see also https://github.com/couchbaselabs/CouchbaseLiteViewer/issues/21


#10

Thank you very much, that gives us big relief!!


#11

Hi there, how can we encrypt data on couchbase lite. I am using phonegap/Cordova. On the Couchbase website I see encryption snippet for ios/swift/android. I dont see anything that indicates how this can be done for cordova. Can you point me to that? Thanks much!!


#12

see



I think you should implement yourself, or just wait.


#13

I have a generic question on Couchbase lite. Can the sync between couchbase lite and couchbase continuously happen as long as the sync gateway is up and running? Does it matter if the app on the tablet is foreground or background? If the app is background will the sync stop?


#14

It depends on the OS. On Android, apps are allowed to use the network while in the background, so the answer is yes. On the other hand, leaving sockets open and processing incoming data will consume power, so users may not like that your app makes the battery drain faster.

On iOS, apps are not allowed to leave sockets open in the background for more than a brief time (like 30 sec?) or to run continuous background tasks. So the answer is no.

On both platforms, you can use OS-specific push notifications — you can set up your server to relay a notification to the device when there are changes available, and this can trigger your app to wake up briefly and sync. The details of push notifications are specific to the OS.


#15

Thank you! We want to use a custom document ID based on our internal data and not use auto generated id to post the document. I have not seen that snippet for Cordova anywhere. Where can this be done before posting the document over?


#16

I think that depend on your docs design.In my case, I use doc’s type concat separator,such as :: ,and concat UUID as doc’s id. such as

MSG::de305d54-75b4-431b-adb2-eb6b9e546014

There is a lot of implementation in javascript,
even you can use couchbase-lite rest api,such as

curl http://127.0.0.1:5984/_uuids?count=10

to generate uuid, it will return as follows.

{"uuids":["b5decd38-12b7-44d9-a9c1-61b07b0d8459","01db4f03-b01a-4d78-a596-a0a1ef2cffed","8c2b13ed-5abc-45e1-9efd-f877c3f04f48","e8f47e14-cda3-4d75-bbf4-7f001df9ba93","ba06c573-10ea-40a6-a749-53f481f2b7eb","5e9613a1-f1bb-47cd-87ea-d7516b4bbf24","68fcd134-1af1-4cba-8ef4-99e9b8afa075","c8eac5c0-9094-49b0-bb41-13f8d7288be0","b3e31409-0309-463b-9902-0050c16fd08b","8bc7f5fc-82e8-4b23-b906-99770e47d3eb"]}

#17

Sorry, I meant to ask, where is the code in todo lite phonegap app to generate this id associate with the document.

I mean the ids are getting posted to the CouchbaseServer like this 09703607-d157-4e19-b33a-2a4b84ed6de8. Where can I explicitly handle this in index.js so that I can assign an ID to each document I post to Sync gateway and not have it auto generate this long id?


#18

If you use post-db API, the id of docs will be auto generated.
but if you use put-db-doc api, you can assign the doc’s id.


#19

Thank you for all your replies!! It worked!!. I have one more question, what is the username and password for localhost:5984? I have not set any for this application. When I try to access it it asks me for username and password.


#20

If you use Couchbase-Lite-PhoneGap-Plugin,username and password is generated by Random,see also:


and

so may be you can print the cbl url to get username and password of cbl. see also: