synchronized document or not?

74 views
Skip to first unread message

Julio Albuquerque

unread,
Mar 14, 2016, 2:27:28 PM3/14/16
to Couchbase Mobile
how to know if a document has already been synchronized or not?
I use Xamarin Android with Couchbase Lite for .NET.
Julio.

Jens Alfke

unread,
Mar 14, 2016, 3:38:51 PM3/14/16
to mobile-c...@googlegroups.com

> On Mar 14, 2016, at 11:27 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:
>
> how to know if a document has already been synchronized or not?

Check if the push replicator has either
- gone to the ‘idle’ state (if it’s continuous)
- stopped with no error (if it’s one-shot)

—Jens

Julio Albuquerque

unread,
Mar 14, 2016, 3:44:04 PM3/14/16
to Couchbase Mobile
I think not explained properly.
I need to consult a document in couchbase.lite and find out if it has been synchronized.
Is there a field in my documents stored locally on couchbase.lite (mobile) indicating this situation?

Jens Alfke

unread,
Mar 14, 2016, 3:58:35 PM3/14/16
to mobile-c...@googlegroups.com
On Mar 14, 2016, at 12:44 PM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

I need to consult a document in couchbase.lite and find out if it has been synchronized.

I understand. What I said is that if the push replicator is up-to-date, then all the docs have been synced to the server.

The Mac/iOS version of Couchbase Lite has an API on the Replicator class to ask whether a specific document revision has been pushed, but that’s not available in .NET yet.

Is there a field in my documents stored locally on couchbase.lite (mobile) indicating this situation?

No. There can be any number of replicators, so there’s not a “to-one” relationship between documents and replicators, and it doesn’t make sense to store replication information alongside a document.

—Jens

Julio Albuquerque

unread,
Mar 14, 2016, 5:04:00 PM3/14/16
to Couchbase Mobile
I need to delete a document after making sure it was synchronized.

I would have to delete the Couchbase Server and replicate to the Couchbase.Lite to be able to delete permanently?

How could I do that?

Jens Alfke

unread,
Mar 16, 2016, 5:33:49 PM3/16/16
to mobile-c...@googlegroups.com

On Mar 14, 2016, at 2:03 PM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

I need to delete a document after making sure it was synchronized.
I would have to delete the Couchbase Server and replicate to the Couchbase.Lite to be able to delete permanently?

I don’t understand the scenario. Could you describe it in more detail?

—Jens

Julio Albuquerque

unread,
Mar 16, 2016, 8:27:15 PM3/16/16
to Couchbase Mobile
My android app has a service that is collecting the geographical coordinates (latitude and longitude).
They are very records daily.
So after sync, I would delete these documents, they will only be used in a plant. And the app android these records are not used, only collected.

Julio.

Jens Alfke

unread,
Mar 17, 2016, 12:16:30 AM3/17/16
to Couchbase Mobile

On Mar 16, 2016, at 5:27 PM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

My android app has a service that is collecting the geographical coordinates (latitude and longitude).
They are very records daily.
So after sync, I would delete these documents, they will only be used in a plant. And the app android these records are not used, only collected.

OK, run a push replication, and after it completes or goes idle, you can purge the docs.

—Jens

Julio Albuquerque

unread,
Mar 17, 2016, 6:42:17 AM3/17/16
to Couchbase Mobile
I tried that but: push.Continuous = true;
I also noticed that when using the code:
push.Changed + = (sender, e) => {
var active = == push.Status ReplicationStatus.Active;
if (! active) {
                                 ....
                                 }
}
Sometimes not finished syncing and (! Active) = true, at another time following synchronization.
So my difficulty in knowing who has already been synchronized to avoid the risk of deleting record that has not been.

What is the guarantee that after synchronization 100% of the documents are synchronized?

Really I do not see a solution for my case.

And also I do not see the dificudade in providing a property on documents like: bool isSincronized, as has isDeleted.

Jens Alfke

unread,
Mar 17, 2016, 12:30:18 PM3/17/16
to mobile-c...@googlegroups.com
On Mar 17, 2016, at 3:42 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

Sometimes not finished syncing and (! Active) = true, at another time following synchronization.

I said to check for `status == Idle`, not `status != Active`.

And also I do not see the dificudade in providing a property on documents like: bool isSincronized, as has isDeleted.

isSynchronized to what? If there are three push replications associated with that database, which one does that flag reflect? Or does it reflect all of them? If so how are they combined?

As I said, it’s not a one-to-one relationship.

Also, it’s not that we can’t implement what you need; it already exists in the Objective-C version. I’m trying to suggest workarounds for Android version, which hasn’t implemented that feature yet.

—Jens
Reply all
Reply to author
Forward
0 new messages