Query returns null

I wrote some document to a bucket

1NR1 {id:1NR1, Type:1NR, p1:0,p2:0,p3:0,p4:0}
1NR2 {id:1NR2, Type:1NR, p1:0,p2:0,p3:0,p4:0}
1NR3 {id:1NR3, Type:1NR, p1:0,p2:0,p3:0,p4:0}

1NR100 {id:1NR3, Type:9NR, p1:0,p2:0,p3:0,p4:0}

I hope to query all documents which ‘Type’ are 1NR

so I created a view(name is ‘1nr’)
view code
function (doc, meta) {
if (doc.Type && doc.Type == “1NR” && doc.id) {
emit(doc.id, null);
}
}

then I executed

var couchbase = require(‘couchbase’);
var db = new couchbase.Connection({host: ‘localhost:8091’, bucket: ‘default’});

var query = db.view(‘1nr’, ‘by_Type’);
query.query(function(err, results) {
for(i in results)
console.log(results[i]); // let’s iterate all documents
});

but it always return null

another question is ‘by_Type’ in
var query = db.view(‘1nr’, ‘by_Type’);
If I hope to query Type, just need to set the by_Type
query id, just need to set the by_id

Is it right?

Your comment welcome

Hi,

If as you said your view is named ‘1nr’, your going to have an issue.

In the following code, the first argument should be the name of the design document and the second one should be the name of the view.

var query = db.view(‘1nr’, ‘by_Type’);

It means you need to create a view named ‘by_Type’ under the ‘1nr’ design document (That you probably need to create too).

Hope it helps.
Cheers!