N1QL - Sync Gateway compatibility

Hi, I think that my use case is pretty common.
I have a big enterprise application, with a lot of data associated. I’m developing this for mobile and web clients. At the moment the application is web-only and has a Sails.js layer that connects directly to a CouchBase Server bucket. To create/update/delete data I use native couchbase SDK for Node.js, and for queries and more complex updates I use N1QL. I have also a layer of security and user management that runs on top of these services.
How can migrate this environment to make it suitable for mobile purposes?
I noticed that CouchbaseLite and SyncGateway are very useful in this case, but I want to mantain the schema of the data in my application, but I also want pull/push replications.
The problems with this implementation are the following:

  1. I want to provide the same security layer for mobile, web and N1QL also.
  2. I want also perform some extra logic on server side when I create/update/delete an object. I can’t do this in SGW sync function because I want to alter properties of other objects once one is created/updated/deleted
  3. I want to make the architecture the simplest and the more scalable possible.
  4. As I said, I want to make the data schema fixed. At the moment for this purpose I use the data validation layer provided by Sails.js
1 Like