Thanks for the example Dominique.
I've implemented the sync process based on your example. However, I still have some issues. I created two document and a user. The app sent the changes to the sync manager and then to the couchbase server. Now, I removed the app, installed it again and stopped the sync gateway. The app started up and I could see in the logs the changes coming from the couchbase server to the sync gateway, but the problem came up in this step. If I try to see the changes through the admin interface (SG) I can see them well. However, if I try to get them from the mobile app, I only get one of them, the one related to the user document.
15:11:28.786582 HTTP: #012: GET /adb/_changes?feed=longpoll&heartbeat=1000&style=all_docs&since=0&limit=100&include_docs=true (ADMIN)
15:11:29.030749 changes_view: Query took 243.893437ms to return 2 rows, options = db.Body{"limit":100, "stale":false, "startkey":[]interface {}{"*", 0x1}, "endkey":[]interface {}{"*", 0x4}}
15:11:29.035647 WARNING: Changes feed: error getting doc "_user/fede": 400 Invalid doc ID -- db.(*Database).addDocToChangeEntry() at changes.go:57
15:11:29.035713 HTTP+: #012: --> 200 OK (0.0 ms)
[The following shows the changes retrieved through the admin interface]
15:44:22.054865 HTTP: #038: GET /vdb/_changes?feed=longpoll&heartbeat=1000&style=all_docs&since=0&limit=100&include_docs=true (ADMIN)
15:44:22.138401 WARNING: Changes feed: error getting doc "_user/fede": 400 Invalid doc ID -- db.(*Database).addDocToChangeEntry() at changes.go:57
15:44:22.138459 HTTP+: #038: --> 200 OK (0.0 ms)
{
results: [
{
seq: 2,
id: "B14D6B41-DB44-404E-A355-43DDB252A81E",
doc: {
_id: "B14D6B41-DB44-404E-A355-43DDB252A81E",
_rev: "1-0c0ff608417c7a4748215a822b61d2ae",
active: true,
createdAt: "2015-01-08T15:19:24.629Z",
id: "record-158",
modifiedAt: "2015-01-08T15:19:24.629Z",
name: "Thu Jan 08 2015 12:19:20",
type: "event"
},
changes: [
{
rev: "1-0c0ff608417c7a4748215a822b61d2ae"
}
]
},
{
seq: 3,
id: "C4315EBA-1C17-4136-AECE-0D1AF33C10BE",
doc: {
_id: "C4315EBA-1C17-4136-AECE-0D1AF33C10BE",
_rev: "1-f2fc940cb0aab6289228e1ef9884ab3f",
active: true,
createdAt: "2015-01-08T15:19:42.406Z",
id: "record-161",
modifiedAt: "2015-01-08T15:19:42.406Z",
name: "Thu Jan 08 2015 12:19:40",
type: "event"
},
changes: [
{
rev: "1-f2fc940cb0aab6289228e1ef9884ab3f"
}
]
},
{
seq: 4,
id: "_user/fede",
changes: [
{
rev: ""
}
]
}
],
last_seq: "4"
}
[The following shows the changes retrieved from the my app]
15:18:52.892483 HTTP: #020: GET /adb/_changes?feed=longpoll&include_docs=true&conflicts=true&style=all_docs&since=1&limit=100
15:18:52.892575 HTTP: #020: --> 401 Login required (2.3 ms)
15:18:53.495125 HTTP: #021: GET /adb/_changes?feed=longpoll&include_docs=true&conflicts=true&style=all_docs&since=1&limit=100 (as fede)
15:18:53.495422 WARNING: Changes feed: error getting doc "_user/fede": 400 Invalid doc ID -- db.(*Database).addDocToChangeEntry() at changes.go:57
15:18:53.495822 HTTP+: #021: --> 200 OK (0.0 ms)
{"results":[{"seq":4,"id":"_user/fede","changes":[]}],"last_seq":"4"}
As you can see, the changes attribute is an empty array here. Could you tell me why is that and how could I get the same changes that I get through the admin interface?