I am trying to achieve the right query for my NoSQL database, but I am confused how to do it in Cloudant. In SQL with be
SELECT * FROM mydb
WHERE user_permit_doc_id = 10
AND user_tracking_id = 1
My query is like:
https://293e2cb7-3561-4004-a1c3-58d54f517ee6-bluemix.cloudant.com/user_files/_design/user_tracking/_view/new-view?startkey=["user_permit_doc_id:10"]
and it returns all of the docs, not just the ones with this id.
this is m Map Reduce function for the View
function(doc) {
if(doc.user_tracking_id !== null){
emit(doc);
}
}
Example of a doc inside my database of docs
{
"_id": "6e57baa78c6415beeee788bc786cc53a",
"_rev": "5-f15352bce99c307bd246bda4dc0da75a",
"user_tracking_id": "1",
"user_permit_id": "2",
"user_permit_doc_id": "10",
"user_id": "1",
"_attachments": {
"6y41j4i68cic.jpg": {
"content_type": "image/jpeg",
"revpos": 2,
"digest": "md5-KC+G5tbz2UWZSzlPHvBy/Q==",
"length": 68367,
"stub": true
}
}
}
you can change your view into
and then query using the complex key [1, 10]