A newer version of this documentation is available.

View Latest

Data Modeling

Property prefix

User properties cannot begin with an underscore (_).

The underscore character (_) is a reserved prefix for system properties of a document (_id, _rev etc.) A document which contains user properties with a leading underscore will be rejected by Sync Gateway with the following error.

"{"error":"Bad Request","reason":"user defined top level properties beginning with '_' are not allowed in document body"}"

This rule applies to writes performed through Couchbase Lite SDKs and Sync Gateway REST APIs. And to writes performed through Couchbase SDKs when Mobile-Web Data Sync is enabled.

If you encounter this error, it is recommended to rename the property without a leading underscore, or to wrap the property prefixed with an underscore in another object whose key isn’t prefixed with an underscore.

More specifically, you may encounter the error in the following deployment configurations:

  • With Mobile-Web Data Sync and Field Level Encryption enabled. This rule conflicts with the default field encryption format.

  • With Mobile-Web Data Sync enabled, the Node.js Server SDK, and Ottoman.js (the Node.js ODM for Couchbase). This rule conflicts with the _type property that is automatically added by Ottoman.js. A suggested workaround in this scenario is to fork the Ottoman.js library, perform a search-replace for the _type property and to rename it without a leading underscore.