This question would be better asked on the couchdb-user mailing list
(see
couchdb.apache.org)
> { emit([doc['template_id'],
> doc['loan_name'],doc['loan_period'],
> doc['loan_amount']],null);}}"
>
> I need to get the whole docs with loan_period > 5 and loan_amount >
> 30000.
What you are asking for is view intersections, which couchdb does not
currently support. You need to do this processing client-side; either
get all the docs with loan_period > 5 and filter them locally for
loan_amount > 30000, or vice versa. In either case you'll need a
different view to the one you already have; either
emit(doc.loan_period,null);
or
emit(doc.loan_amount,null);
so that you can ask for startkey=5 or startkey=30000
> My startkey and endkey parameters are like this:
>
> params = {:startkey =>["7446567e45dc5155353736cb3d6041c0",nil,
> 5,30000],
> :endkey=>["7446567e45dc5155353736cb3d6041c0",{},{},{}],:include_docs
> => true}
What you have asked for is all documents between key [a,b,c,d] and
[w,x,y,z], and that's exactly what you'll get. All keys are sorted
into a single linear list, so you'll get everything in between these
values. e.g. if the emitted keys look like this:
[a,a,a,a]
[a,b,b,b]
[a,b,c,d] \
[a,f,g,h] |
[b,a,a,a] | these keys fall within the range given
[c,a,z,a] | so will be returned by the query
[w,a,a,z] |
[w,x,y,z] /
[w,z,a,a]
For more info see "view collation" on the CouchDB wiki:
wiki.apache.org/couchdb