best way to add "last updated" timestamp on document

248 views
Skip to first unread message

Seung Chan Lim

unread,
Jul 20, 2014, 7:21:56 PM7/20/14
to mobile-c...@googlegroups.com
Hi, 

I was wondering if there is a "best practice" way to put last updated timestamp on a document other than doing it on the client side. I hope to synchronize the clock on the server.

I'm currently writing the client app using cb-lite on iOS replicating through sync gateway to couch base.

Ideally, I'd love to find out if there's a way to put a "last updated" time stamp in the context of something like the sync function. But I don't see such a thing.

I suppose I could run a daemon on the server machine alongside the sync gateway that gets change notification on the document I want to stamp and stamp it. I was hoping I could do this without having to run such a thing separate. 

thank you,

slim

Jens Alfke

unread,
Jul 20, 2014, 11:19:35 PM7/20/14
to mobile-c...@googlegroups.com

On Jul 20, 2014, at 4:21 PM, Seung Chan Lim <djs...@gmail.com> wrote:

Ideally, I'd love to find out if there's a way to put a "last updated" time stamp in the context of something like the sync function. But I don't see such a thing.

No, because that would alter the document and create a new revision.

Also, it wouldn’t be the actual time the document was updated, just the time that the updated document was received by the server from the client (which could often be minutes or hours later.)

In a distributed system like this, document updates are performed by the client. If you want a server-synchronized timestamp on a document, then you have to have the server do the updating, which brings you back to a traditional client-server system that has to be online to function.

—Jens

Seung Chan Lim

unread,
Jul 21, 2014, 12:32:57 AM7/21/14
to mobile-c...@googlegroups.com
Ah… good point. Hmm...

Shawn Murphy

unread,
Sep 2, 2014, 6:22:41 PM9/2/14
to mobile-c...@googlegroups.com
Is there anyway of getting the sync-gateway "time_saved" metadata in the "_sync" property available on a CBL client? I would think that a server side time-stamp is critical for any communication/messaging applications. Knowing the life of a message helps determine the value of the information, which I think would include when it was created and when it became publicly available.

v/r,
Shawn

Jens Alfke

unread,
Sep 2, 2014, 6:47:35 PM9/2/14
to mobile-c...@googlegroups.com
On Sep 2, 2014, at 3:22 PM, Shawn Murphy <sdmu...@gmail.com> wrote:

Is there anyway of getting the sync-gateway "time_saved" metadata in the "_sync" property available on a CBL client?

No; if that were added to the document by the server, it would result in a new revision of the document, which would then get pushed back to all clients.

The Sync Gateway doesn't create revisions, it just routes them.

I would think that a server side time-stamp is critical for any communication/messaging applications. Knowing the life of a message helps determine the value of the information, which I think would include when it was created and when it became publicly available.

It's more complex than that, because replication doesn't just have to be with a single server. If you replicate a document to two servers (or to a server plus a local client via p2p) what should the "time_saved" be? What if there's another server that pulls from your server and has clients replicating with it?

I've been working on a blogging app as a spare-time project, and I have the client in charge of adding timestamps to documents. (I haven't yet need any 'smarts' in the server at all. It just lets the clients replicate with each other.)

—Jens
Reply all
Reply to author
Forward
0 new messages