Query sync gateway

Hi all,
Is there a way to create n1ql query on Sync gateway?
Or should i query couchbase server syncronized document , using n1ql?
For what I know syncronaized json document , have a special schema on couchbase server (include some special fields). So n1ql can query as well these documents syncronized?

yes, _sync fields will be added in document.
I think you can query syncronized document from couchbase server by N1QL that remove sync fields when query data.

So there is no way to query gateway?

you can query by view.
FYI
https://developer.couchbase.com/documentation/mobile/1.4/guides/sync-gateway/views/index.html

Future versions of Sync Gateway will make it much easier to run N1QL queries against it – in the meantime it’s clunky and there may be some caveats, and it’s not documented or tested, so you’re pretty much on your own.

As @atom_yang mentioned, map/reduce views are supported, and they essentially “pass-through” to the backing Couchbase Server.

1 Like