cloudant / nodejs-cloudant

Cloudant Node.js client library
Apache License 2.0
255 stars 90 forks source link

Passing group_level to view #138

Closed atulatgithub closed 8 years ago

atulatgithub commented 8 years ago

Hello, I tried passing group_level to view using below syntaxes

params = { reduce: true, group_level: 2 } params = { "reduce": "true", "group_level":"2" }

However, cloudant is not grouping it. Its returing around 72k records. If I test it through browser its its returning correct records.

@glynnbird

glynnbird commented 8 years ago

Code of this form works just fine:

var Cloudant = require('cloudant');
var cloudant = Cloudant({ url: "https://reader.cloudant.com"});
var mydb = cloudant.db.use('abcde');
mydb.view('test','newview', { group_level:2, reduce:true}, function(err, data) {
  console.log(err, JSON.stringify(data));
});
atulatgithub commented 8 years ago

Not working. Still returning 72k records.

DaniloOliveira28 commented 8 years ago

mydb.view('test','newview', { group:true, group_level:2}, function(err, data) { console.log(err, JSON.stringify(data)); });

atulatgithub commented 8 years ago

Sorry for both of you. Some silly issue from my side. I forgot that my view has complex keys. First key is an array of [Brand, Model, State, City etc]

I want to group by Brand or Brand/Model or Brand/Model/State. Is this possible?

Below is example. I want to group by first key elements. i.e by My view is like this [ [ "LG", "WD100CW", "Florida", "Coral Springs", "33067", "2016", "1", "2" ], "Saturday" ], value: { sum: 1, count: 1, min: 1, max: 1, sumsqr: 1 }

Really sorry to both of you.

DaniloOliveira28 commented 8 years ago

https://wiki.apache.org/couchdb/Introduction_to_CouchDB_views