0

I want to query couchdb the same way I do mysql first using a url and also using nano:

SELECT * FROM people WHERE email = 'john@smith.xxx' AND password = 'password'

In nano I created my view:

db.insert(
  { "views": 
    { "byLogin": 
      { "map": function (doc) { if (doc.email === 'john@smith.xxx' && doc.password === 'password') emit([doc.firstname, doc.lastname], doc); } 
    }
  }, '_design/people', function (error, response) {
    console.log(response);
  });

Trying to run the query in futon. So far the only reference I have found is the below:

http://127.0.0.1:5984/people/_design/people/_view/byLogin/?key=["john@smith.xxx","password]

Doesn't return any results. Any ideas?

In Nano I tried all the examples on github. This is the last one tried.
bd.view_with_list('people', 'byLogin', 'john@smith.xxx,password', function(err, body) {
  if (!err) {
    console.log(body);
  }
});

Not working.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
razor8088
  • 293
  • 2
  • 8

1 Answers1

0

This code does not work because sql query runs when you read data from a database, but couchdb view runs when you save data to a database.

Anthony
  • 12,407
  • 12
  • 64
  • 88