The canonical solution would be to have two views, one by email and one by id. To not waste space for the document, you can just emit null as the value and then use the include_docs=true
query paramter when you query the view.
Also, you might want to use _id
instead of id
. That way, CouchDB ensures that the ID will be unique and you don't have to use a view to loop up documents.