Arun M R Nair
Arun M R Nair

Reputation: 653

How can i write query with OR case in couchdb

I want to write a query in couchdb same as below sql.

select * from tbl_name where f_name like 'a%' or l_name like 'a%';

for the given document:

{

"f_name":"abc",

"l_name":"def"

}

I need result by using view and its should not use any list.Alternatively i want to change the field name in where case.

eg:

select * from tbl_name where f_name like 'a%' ;

select * from tbl_name where l_name like 'a';

The field name present in where condition should be dynamic.

Upvotes: 1

Views: 249

Answers (1)

Daniel
Daniel

Reputation: 8368

For wildcard query, have a look here: How to write wildcard search query in couchdb where name like 'a%'

In your view, just output both f_name and l_name as keys, two emits that is.

Upvotes: 1

Related Questions