Dynamic key generation in map function

What is solution for dynamic SQL we generate, for instance consider a filter form which has all fields that user can filter ( customer name, tel, address, state,…)
in sql world I would generate a dynamic sql condition part by fields that user has filled out.

select *
from x
where [condition1] and [condition2] and [condition3]

conditions are optional and will be concatenate in runtime.
consider the number of options is predefined for example there are only 3 options which can participate in condition part and options are not infinite.
what is the best solution for these kind of situation?

Guys, Is there anybody out there?
just a suggestion that’s all i need.

It’s not as automatic as that … you’d probably create a separate view for each of the possible conditions. Then query each view and find which document appears in each query results.

(Alternatively you could create a separate view for each possible combination of conditions, but that’s probably too many views!)

Another possibility, if you’re on iOS, is to use the new CBLQueryBuilder class in release 1.1. It lets you assemble your own predicates to search on.

We are working on an accounting mobile application, so we have about 20 document type and trying to migrate application from sqlite to couchbase lite.
does having too much views bring up performance concerns ?
what is best solution for this type of applications in couchbase world?
sqlite was serving very well but couchbase sync ability is wonderful.

Too many views is a similar problem to having too many SQL indexes. But in SQLite it slows down inserts, while in CBL view indexes are updated lazily, so the first query after a lot of documents were added can become slow.

Performance depends on a lot of factors like the speed of the device, the size of the data set, the complexity of the map function, and the amount of data the map function emits.