Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6738073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:19:26+00:00 2026-05-26T11:19:26+00:00

I have couchdb and document my_users whitch looks like: _id password email … how

  • 0

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 ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:19:26+00:00Added an answer on May 26, 2026 at 11:19 am

    You can emit both the _id and password together.

    function(doc) {
      var key;
      if(doc.resource == "my_users") {
        key = [doc._id, doc.password];
        emit(key, null);
      }
    }
    

    To find a username/password match, search for the same key.

    var username = 'myuser';
    var password = 'secret';
    var key = [username, password];
    this.db.view('users/byUsernamePassword', {"key":key}, function(err, doc) {
      console.log("Result:");
      console.dir({"err":err, "doc":doc});
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following document in a couchdb database: { _id: 000013a7-4df6-403b-952c-ed767b61554a, _rev: 1-54dc1794443105e9d16ba71531dd2850,
Using CouchDB , I currently have a document which represents an idea, you can
I have documents like this in my CouchDB: { _id: 0cb35be3cc73d6859c303fa3200011d2, _rev: 1-f6e356bbf6ab09290aae11132af50d66, adresse:
I have a CouchDB update handler and would like it to return a response
CouchDB, version 0.10.0, using native erlang views. I have a simple document of the
Can CouchDB handle thousands of separate databases on the same machine? Imagine you have
I would like to use CouchDB to store some data for me and then
Given that I have some number of documents in my CouchDB database, I would
I like an idea of document oriented databases like CouchDB. I am looking for
I have errors when updating document in Couchdb 1.1.0 after updating it from 1.0.1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.