No you cannot add serverside logic in the current release Couchbase Server. The main reason is -predictable- performance, if you start to add such logic in the server it may impact the performance.
For the Sync Gateway you have:
- data routing to channels. channel access control. This is the sync function
- asynchronous workers – eg a server process that follows the changes feed for a few channels and does work based on what documents come through changes.
You can find example of this here: