Created
July 28, 2011 15:03
-
-
Save vojtech-dobes/1111705 to your computer and use it in GitHub Desktop.
Fetch the user: MySql vs CouchDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT `*` FROM `users` WHERE `username` = "john@doe.com" AND `password` = "xxx" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// design document | |
{ | |
"_id": "_design/user", | |
"_rev": ... something ..., | |
"language": "javascript", | |
"views": { | |
"credentials": { | |
"map": "function (doc) { | |
if (doc.type == 'user') { | |
emit([doc.username, doc.password], null); | |
} | |
}" | |
} | |
} | |
} | |
// user document | |
{ | |
"_id": ... something ..., | |
"_rev": ... something ..., | |
"type": "user", | |
"username": "john@doe.com", | |
"password": "xxx" | |
} | |
// http://127.0.0.1:5984/db_name/_design/user/_view/credentials?key=["john@doe.com","xxx"]&include_docs=true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment