CBLite, Couchbase server and sync gateway

Hi,

For an enterprise android application, we had used SQLite architecture so far. This application collects specific data and uploads into the server. We were handling sync by ourselves. Now, as we looked into couchdb, we are interested in knowing how it works with respect to our application. While implementing, we got stuck and the following questions arise.

  1. Following the couchbase for android tutorial, I created a simple application, whose data gets replicated into couchbase server using sync gateway. After replication, I found some meta data which we intend to ignore. When I inserted the data, it was found to be in the following structure.

{
"_sync": {
“rev”: “1-5aca82e9-e4cc-47db-9cce-fe32fea68d1c”,
“sequence”: 1,
“history”: {
“revs”: [
“1-5aca82e9-e4cc-47db-9cce-fe32fea68d1c”
],
“parents”: [
-1
],
“bodies”: [
""
],
“channels”: [
null
]
},
“time_saved”: “2014-04-26T14:58:37.399871861+05:30”
},
“check”: false,
“created_at”: “25-04-14”,
“text”: “this is a demo”
}

In the above structure, our data were Check, created_at and text. In the server, I need only this structure to be noticed. But I could not get enough information in order to achieve this.

  1. After replication, I notice 4 documents per sync. Their document ID are as follows:

ID: 78e2c7dc-da9a-42f4-95a6-03bd6cea7b6e
Data: {
"_sync": {
“rev”: “1-5aca82e9-e4cc-47db-9cce-fe32fea68d1c”,
“sequence”: 1,
“history”: {
“revs”: [
“1-5aca82e9-e4cc-47db-9cce-fe32fea68d1c”
],
“parents”: [
-1
],
“bodies”: [
""
],
“channels”: [
null
]
},
“time_saved”: “2014-04-26T14:58:37.399871861+05:30”
},
“check”: false,
“created_at”: “25-04-14”,
“text”: “this is a demo”
}

ID: _sync:local:a7e278f189bb5954e0bae030cf2dd2b231a7318e
Data: {
"_rev": “0-1”,
“lastSequence”: “1”
}

ID: _sync:seq
Data: 5

ID: _sync:syncdata
Data: {
“Sync”: “function(doc) {channel(doc.channels);}”
}

I believe that the first data is recognized as bulk_docs. I’m using sync gateway during replication. How to achieve my requirement? I looked at the beer sample and the data seems to be represented in such a clean manner. But when I perform replication, these irregularities occur.

The bucket used for storage by Sync Gateway should be treated as private to the gateway. Ideally you shouldn’t look at its contents. If you do want to access it (read-only) you should ignore any document whose ID is prefixed with “sync:”, and the “_sync” JSON property of any remaining documents.

If you want to work with the synced application data on the server, you can either use the Sync Gateway’s REST API (which is compatible with CouchDB’s) or you can set up the “bucket shadowing” feature to set up two-way mirroring of the Sync Gateway data with a bucket of your own. The bucket of your own will not have the metadata and you can read and write it as you wish; any changes you make will get synced back to the Gateway.

–Jens