Multiple attachments created through Couchbase Server

We’re building an application which allows users to fill in a form on a mobile app, allowing photo’s to be attached.
These forms are viewable and editable from a web application which used direct queries to Couchbase Server. Is it possible to create multiple attachments direct using the couch base server SDKs or N1QL queries?

The current method I found that would work has quite a cumbersome procedure:

  1. Multiple requests come in from the web app to an API (to ensure the requests aren’t too large with multiple attachments)
  2. Retrieve latest revision of the document using a request to the Sync Gateway (_raw endpoint, as described in https://blog.couchbase.com/shared-access-couchbase-database-web-mobile-apps/)
  3. Send request to Sync gateway to create new attachment for document, including received revision property

This method has not been tested and does not sound too complicated, however, I can see multiple issues:
In step 2 and 3, when 2 requests are executing at the same time, they might retrieve the same revision property which they use to create a new attachment, causing an error due to the revision already existing.
I can chain up the request, so 1 waits for the previous one to finish, but this process is not really optimal.

I read a Sync Gateway 2.0 version is coming soon, does this have any changes/improvements to the attachment system, if so, we’ll leave this part for now and wait for the new version to become available.

No, for any changes to the attachements its best to go through the sync gateway REST API with Attachements.
It will keep the history and the sha1 digest information consistent.

No, you will still have to go through SG REST API for attachment changes