zemirco / couchdb

CouchDB client in Go
MIT License
44 stars 14 forks source link

Add example to show how to use db.View #5

Open zyfdegh opened 7 years ago

zyfdegh commented 7 years ago

Well, I got stuck to use db.View() to query filtered data from CouchDB. I have carefully looked up view_test.go but I'm confused about the _design database. Is the possible to query filtered data without setting _design/* database? Could you(or anyone) please add an example under example/ directory to show how to use it?

zyfdegh commented 7 years ago

The question can be simplified as following

  1. I save the following data to database user,
    {"username" : "admin","password" : "$2y$05$hvbfzxywSeQjlF28XpLQCeiHZpTkO7od9xmKtki2XGTNkG0njtI6q"}
    {"username" : "user2","password" : "$2y$05$H/7thIYBrgl/c3P3Mjmm5u6Y/xuXAwnNRfLI6ib50/7C41fOhpxOG"}
  2. I want to query the document where username==admin from the database. If any doc matches, I will compare the password.

Then, how?

zemirco commented 7 years ago

That sounds more like a general question about querying CouchDB. The question is not directly related to this library. Please try http://stackoverflow.com/questions/tagged/couchdb.