Skip to content

Instantly share code, notes, and snippets.

@vojtech-dobes
Created July 28, 2011 15:03
Show Gist options
  • Save vojtech-dobes/1111705 to your computer and use it in GitHub Desktop.
Save vojtech-dobes/1111705 to your computer and use it in GitHub Desktop.
Fetch the user: MySql vs CouchDB
SELECT `*` FROM `users` WHERE `username` = "[email protected]" AND `password` = "xxx"
// 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": "[email protected]",
"password": "xxx"
}
// http://127.0.0.1:5984/db_name/_design/user/_view/credentials?key=["[email protected]","xxx"]&include_docs=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment