Details
-
Improvement
-
Resolution: Done
-
Major
-
None
-
None
Description
Sync Gateway will not process documents that have a top level attribute that begins with an underscore ("_").
The reason for this is that Sync Gateway is backwards compatible with V1.0 of replication protocol which is based on CouchDB as well as other internal system level properties.
So applications that create documents that are expected to be processed through the Sync Gateway must be aware of this when modeling their data. This is true whether the document is created through the CBS SDK or SGW API or CBL. Failure to do so will result in a Sync Error of the form ""error":"Bad Request","reason":"user defined top level properties beginning with '' are not allowed in document body"}_"
This makes integrations with apps that typically use some ORM/ODM (ottoman etc) that automatically injects some top level underscore "_" prefixed properties difficult requiring workarounds such as using eventing service to strip off the reserved property.
Ottoman.js for instance inserts "_type" and spring boot inserts "_class" keys
Technically, there are only a certain set of underscore prefixed properties that need to be restricted. There is no requirement for sync gateway to restrict the use of all underscore prefixed entities.
The proposed enhancement is to enable Sync Gateway to allow support for top level underscore prefixed properties outside of the reserved ones (_id,_rev,_sync etc).