Reputation: 135
Is it possible to make a view in Couchbase for something like id=A OR name=A ?
Thanks.
Cheers, Yann
Upvotes: 2
Views: 318
Reputation: 2474
No it's not possible to do this on two separate fields within a view. If your query has to be something like:
Select all users where user.id = X or user.name = X
Then you'll need two separate views, one for each field that you want to filter on, then you'll need to combine the results in your application layer.
You can do an OR operation on a single field by passing an array of keys to the view, assuming you have a view which emits the name field then you could pass ["Yann","Peter"] as keys and that field would be matched on either value A OR value B (you can pass more than 2 keys).
Hope that helps!
Upvotes: 3