GetExistingLocalDocument vs GetDocument

What is the difference between GetExistingLocalDocument and GetDocument? shows they both return a Couchbase Document.

GetExistingLocalDocument only returns local documents that the GetDocument method won’t return.

Local Documents a treated separately by Couchbase Lite and cannot be replicated to other databases or indexed in views.

They are handy for storing configuration data or other information that pertains only to the local database.

See this guide for requirements on creating local documents

Your answer and the docs are confusing. Specifically this phrase: “cannot be replicated to other databases”. Does this mean local documents are stored only on the node that received them, and are not replicated to other nodes? Or does this mean they are replicated across the local cluster, but not across XDRC to other clusters?

Weirdly, local documents seems to be a Couchbase Mobile specific thing.

Hi @Nirvana,

Yes, a local document can be persisted to Couchbase Lite or Sync Gateway and will never be replicated. Furthermore, there’s no api to query all local documents so if you save a local document and want to retrieve it later, you’ll have to keep the doc id somewhere else in the application (NSUserDefaults on iOS, SharedPreferences on Android for example…).
In this context I was talking about local documents for Couchbase Mobile.

1 Like