"time_saved" not accessible on Couchbase Lite iOS?

Hi, time_saved not accessible, i know it is useful for Internal usage , is there any alternative to save Server Date time on our own documents with our own properties.

We have a chance to save our system date time by using CBLJSON.JSONObjectWithDate(NSDate()) in Couchbase Lite iOS (Swift2.0), but some users may have chance to change their device date and time, so how can i overcome such problems.

** Is there any CBL properties or functions available for store Server date time on our own documents.**

1 Like

Can you explain a bit more what you mean by server date time?

You could remove the user’s timezone from the NSDate instance you’re saving on the document which would put all times on the same clock. But I’m not sure if that’s what you want to achieve.

James

@jamiltz, thanks for reply.

What I mean is, I’m creating one document, I want to save document created date and time in document with property name of created date, so for that I have to ad my device NSDate, this dates gives current my iPhone date.

For example I will create document at Nov 19th 2016 9:9am IST but my current system date I was changed to Dec 10th 2014. So it’s wrong I want exact date of today.

Is there any possibility to keep server or database date( server maintaining system date time) on document.

if you observer document, there is one date with property called “time_save”, I want that property to use or else I want like that property to create and insert server date time there.

Ok, then you will need a network connection and to use a server side endpoint for any write/update that requires the server side timestamp. Would the suggestion below work in your case?

James

Ok, nice thought its is, but can you please assist me, how to write code in Sync Gateway. Why to do like this more steps. better to keep on property under CBLJSON class in Couchbase Lite, so any one can access easily.

Once the document is written to Couchbase Lite, there’s no way to change that unless you create a new revision for it. That’s why you need to persist the document to Sync Gateway on the server side with this endpoint or this one.

James

Thanks for quick reply, but these are rest APIs. But sometimes, we don’t have Internet, so its not good one for me. one more thing, what i’m suggest to CouchBase Team is, keep one method that will give server Date and time stamp at run time not at compile time, like Time_Saved property is used for Couchbase Internal purpose.

From this github issue, I read more about the update function in CouchDB and it looks like this is the functionality you need but it’s not implemented in Sync Gateway.

You can open a feature request ticket on Github.

James