@nick-couchbase
To validate that your view is created correctly and that it is processing documents you can do the following:
First look at the view via the Couchbase Server Admin Console, if it was created after the āunsupportedā property was added to the database config it will contain additional channel processing.
e.g. A view created in SG 1.2 without the āunsupportedā configuration:
{
"views":{
"all_lists":{
"map":"function(doc,meta) {
var sync = doc._sync;
if (sync === undefined || meta.id.substring(0,6) == \"_sync:\") return;
if ((sync.flags \u0026 1) || sync.deleted) return;
delete doc._sync;
meta.rev = sync.rev;
(
function (doc, meta) {
if (doc.type != \"list\") { return; }
emit(doc.title, doc.owner);
}
)
(doc, meta);
doc._sync = sync;
}"
}
}
}
The same view created in SG 1.2 after the āunsupportedā property was added to the SG config:
{
"views":{
"all_lists":{
"map":"function(doc,meta) {
var sync = doc._sync;
if (sync === undefined || meta.id.substring(0,6) == \"_sync:\") return;
if ((sync.flags \u0026 1) || sync.deleted) return;
var channels = [];
var channelMap = sync.channels;
if (channelMap) {
for (var name in channelMap) {
removed = channelMap[name];
if (!removed)
channels.push(name);
}
}
delete doc._sync;
meta.rev = sync.rev;
meta.channels = channels;
var _emit = emit;
(function(){
var emit = function(key,value) {
_emit(key,[channels, value]);
};
(function (doc, meta) {
if (doc.type != \"list\") { return; }
emit(doc.title, doc.owner);
})
(doc, meta);
}());
doc._sync = sync;
}"
}
}
}
If the channel processing is present then you can use the CBS Admin Console to process some documents by clicking on the āShow Resultsā Button. You should see results similar to:
"docID" [ [ "list--9swubvIT19JnxLT28todis" ], "p:10153954222643362" ]
If this is working and you are not seeing any rows when you query a view via the REST API then it is most likely that your user does not have any documents (for which rows are emitted by the view) tagged with any channels the user is assigned.
You can validate that by calling _all_docs
on the User REST API (with user authentication) and check to see if any of the documents should be emitted by the view e.gā¦
curl -X GET http://localhost:4984/db/_all_docs