I have couchdb and document my_users whitch looks like:
_id
password
email
...
how can I select _id for _id and password.
I would like sth like mysql select _id from my_users where _id = "mylogin" and password = "mypassword"
i using cradle
and trying sth like this:
db.save('_design/user', {
views: {
byUsername: {
map: 'function (doc) { if (doc.resource === "my_users") { emit(doc._id) } }'
}
}
});
this.db.view('user/byUsername', { key: 'myuser' }, function (err, doc) {
console.dir(doc); ///this is empty array :|
});
but it doesn;t work correctly how to use it ??
You can emit both the
_idandpasswordtogether.To find a username/password match, search for the same key.