Document 2.0 - getCurrentRevisionId() equivalent

With the new 2.0 how do I getCurrentRevisionId()?
Also, is there meta data that I can get that would indicate if the document instance has ever been saved?

We don’t expose the revId . The only meta info that we expose is doc Id and sequence Num. Is there a reason you want this value ?

In my current code, I check if a document ‘isNew’, ie if it has ever been written to disk, and act on that accordingly. In code I do: if(document.getCurrentRevisionId()==null)
So, without having to dig too deep into my framework, I just want to replace the code with the new api.

You could do a getDocument(id) on Database to see if document exists. It will return nil if doc does not exist.

I am looking for the call on the document, within the document, without calling the db.
Your api supported this, please continue to do so.

For reasons other than how your code is possibly structured, it is unclear to me as to why you can’t use the API above that gives you exactly what you need - which as I understand is to determine if a document exists in the db or not.

Please bear in mind that the 2.0 API is significantly different from 1.x version so you will have to prepared for many more instances where a direct search and replace of the 1.x API with 2.x counterpart won’t be possible and is probably not recommended .

There are reasons why the revID is not exposed. It is intended to be treated as an opaque object whose format is subject to change and we did not want developers to interpret it in any way and potentially misused.

So if you can specify a reason why you can’t do what you want to without having access to revID,we will consider exposing the revID.

The Sequence of a document will always be 0 if it has not been saved, and will always be non-zero once it is saved. Note that this is not updated on the object that was saved. The save method returns a new instance with the saved properties included.

  1. You need not expose the revID in itself, just a public method (which likely extrapolates that from the private revID) that returns true if the document was ever written to disk (or vice versa).
  2. There are scenarios where I have a document but NOT the db available in a particular process.
    2b Why access the disk - and all its overhead - when I can do it in ram?


Aye, thanks! That’s all I was looking for. A quick correct answer. Just want to get my work done and am faced with this task of upgrading to the new api…

The database should be the source of truth unless you have a single writer.