couchdb - Creating view to check a document fields for specific values (For a simple login) -


i'm new cloudant , pardon me question. creating simple mobile game login system checks username(email) , password.

i have several simple docs in format

{     "_id": "xxx",     "_rev": "xxx",     "password": "3o+k+o8bxsxu0kulsbuiww==", --encrypted application beforehand     "type": "user",     "email": "asd@asd.com" } 

right can't seem correct 'formula' creating view (map function) whereby network request , pass both email , password. if there doc matches email, check doc.password against passed value. if matches, function should return simple "yes".

for map function follows, returns docs .

function(doc) {     if (doc.email){         index("password", doc.password, { store : true });         if (doc.password){              emit("yes");         }     } } 

it may request format wrong. right follows. values not real, format checking

https:/etcetc/_design/app/_view/viewchecklogin?q=email:"asd@asd.com"&password:"asd" 

it looks have misunderstood how views supposed work. in general cannot perform logic return different result based on request. query parameters in view request can used limit result set of view entries returned or return grouped information reduce function.

to determine if there match given username , password emit values keys , query them. return view entry keys or empty list if there no match. i'd cautious security here. access view able see view entries, i.e. usernames , passwords.


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -